Reputation: 61
I want to share post from graph api in python
import requests
import urllib
host = "https://graph.facebook.com"
path = "/oauth/access_token"
params = urllib.urlencode({"client_id":"XXXXXXX","client_secret": 'XXXXXXXXXXXXXXXXXXXXXXXXX','grant_type': 'client_credentials'})
url = "{host}{path}?{params}".format(host=host, path=path, params=params)
r = requests.get(url)
print "r",r
payload = {'grant_type': 'client_credentials', 'client_id': 'XXXXXXXXXXXXXXX', 'client_secret': 'XXXXXXXXXXXXXXXXXX'}
file = requests.post('https://graph.facebook.com/oauth/access_token?', params = payload)
result = file.text.split("=")[1]
print "result",result
param = {'client_id':'XXXXXXXXXXXX', 'access_token':result}
file_one = requests.post('https://graph.facebook.com/oauth/access_token_info?', params = param)
print "access token info file",file_one
print "access token info file.text",file_one.text
host = "https://graph.facebook.com"
path = "/me/feed"
params = urllib.urlencode({"message":"Hello, World.","access_token": file.text.split("=")[1]})
url = "{host}{path}?{params}".format(host=host, path=path, params=params)
r = requests.post(url)
print "value of r",r
print "r.text",r.text
i get token but when i try to post in fb so it return error like
{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500,"fbtrace_id":"G3PcKSN1mFA"}}
in facebook three types of tokens 1)user token 2)app tokens 3)page token but i required usertoken from above script i get app token not user token can you please give solution fo how we get user token
Upvotes: 0
Views: 118
Reputation: 61
hi i found my solution from get app-access token and then convert them in to user access token this link is useful for me
Facebook Graph API: Have app access token, need user access token without interaction
Upvotes: 0