forked from sns-sdks/python-facebook
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget_facebook_post_info.py
More file actions
29 lines (21 loc) · 821 Bytes
/
get_facebook_post_info.py
File metadata and controls
29 lines (21 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
This is an example for get post detail by FacebookApi class.
Refer: https://developers.facebook.com/docs/graph-api/reference/pagepost
"""
import os
from pyfacebook import FacebookApi
APP_ID = os.environ.get("APP_ID") # Your App ID
APP_SECRET = os.environ.get("APP_SECRET") # Your App secret
ACCESS_TOKEN = os.environ.get("ACCESS_TOKEN") # Your Access Token
def handler(post_id):
api = FacebookApi(app_id=APP_ID, app_secret=APP_SECRET, access_token=ACCESS_TOKEN)
post = api.post.get_info(
post_id=post_id,
fields="id,message,created_time,full_picture,status_type,updated_time",
)
print(f"ID: {post.id}")
print(f"Time: {post.created_time}")
print(f"Data: {post.to_json()}")
return True
if __name__ == "__main__":
handler(post_id="19292868552_371106181716390")