I am trying to publish to my Facebook wall from my site. I have logged in to my site with Facebook and have also granted publish_actions permission but when I try to publish to Facebook I get error.
Facebook says I can publish to user's wall by making an HTTP POST request as below:
POST graph.facebook.com
/{user-id}/feed?
message={message}&
access_token={access-token}
user-id, message and access-token[token is long-lived] are fine and correct as returned by Facebook API call response.
I have also pip install requests, an elegant and simple HTTP library for Python, built for human beings
My code:
import requests
if user.publish:
message = post_message.encode('utf8')
url = "https://graph.facebook.com/{0}/feed".format(user.facebook_id)
msg = {'message':message, 'access_token':user.access_token }
r = requests.post(url, data=json.dumps(msg))
return HttpResponse(r)
The code returns the error below:
{"error":{"message":"Unsupported post request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api","type":"GraphMethodException","code":100}}