Answer the question
In order to leave comments, you need to log in
How to get access_token for facebook in python?
Please tell me how to get access_token for facebook.
Tried like this:
import facebook
import requests
FACEBOOK_APP_ID = 'XXXXXXXXXXXXXXX'
FACEBOOK_APP_SECRET = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY'
""" # old version
payload = {
'grant_type': 'client_credentials',
'client_id': FACEBOOK_APP_ID,
'client_secret': FACEBOOK_APP_SECRET
}
file = requests.post('https://graph.facebook.com/oauth/access_token?', params = payload)
oauth_access_token = file.text.split("=")[1]
"""
oauth_access_token = "|".join([FACEBOOK_APP_ID, FACEBOOK_APP_SECRET])
graph = facebook.GraphAPI(access_token = oauth_access_token, version = '2.2')
groups = graph.get_object("me/groups")
group_id = groups['data'][1]['id']
graph.put_object(
group_id,
"feed",
message = instance.text,
link = instance.get_short_absoluteurl(),
picture = instance.img_url_absolute
)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question