django - Automatically posting to facebook page with python -
i want make script lets me post facebook fan page (which i'm admin of)
as far i've seen, graph api examples making facebook apps in python , make them communicate python, quite different want.
also graph api requires oauth token, documentation claims it's obtained doing:
https://www.facebook.com/dialog/oauth? client_id=your_app_id&redirect_uri=your_url
i think implies:
a) have create facebook app this, didn't think necessary (after it's require standard credentials , wouldn't used other people), fine. have app created task.
b) need url, don't have, because it's script.
any ideas on should info?
first need facebook_app_id , facebook_app_secret, facebook when register app.
then include needed urls.
redirect_client_url = 'http://your-redirect-url' access_token_url = 'https://graph.facebook.com/oauth/access_token?client_id='+consumer_key+'&redirect_uri='+red irect_client_url+'&client_secret='+consumer_secret+'&code=' scope = 'publish_stream,offline_access,user_birthday,email' authorize_url = 'https://graph.facebook.com/oauth/authorize?client_id='+consumer_key+'&redirect_uri='+redirect_client_url+'&scope='+scope+'&display=touch' user_info_url = 'https://graph.facebook.com/me?access_token='
your consumer key , consumer secret facebook app id , facebook app secret respectively.
you access_token following oauth2.0 guidelines , store access_token , fan page idsomewhere in database. https://github.com/simplegeo/python-oauth2 example on how oauth token. when try post use access token using this.
post_data = {'access_token':access_token, 'message':'hey test!'} request_path = str(facebook_id)+'/feed' post_data = urllib.urlencode(post_data) response = urllib2.urlopen('https://graph.facebook.com/%s' % request_path, post_data)
this should work posting user's wall. sure posting facebook fan page should similar.
Comments
Post a Comment