Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Update 2018-08-23</strong></p> <p>Since this still gets some views and upvotes I just want to mention that by now there seems to exist a maintained 3rd party SDK: <a href="https://github.com/mobolic/facebook-sdk" rel="nofollow noreferrer">https://github.com/mobolic/facebook-sdk</a></p> <hr> <p>Better late than never, maybe others searching for that will find it. I got it working with Python 2.6 on a MacBook.</p> <p>This requires you to have</p> <ul> <li>the Python facebook module installed: <a href="https://github.com/pythonforfacebook/facebook-sdk" rel="nofollow noreferrer">https://github.com/pythonforfacebook/facebook-sdk</a>,</li> <li>an actual Facebook app set up</li> <li>and the profile you want to post to must have granted proper permissions to allow all the different stuff like reading and writing.</li> </ul> <p>You can read about the authentication stuff in the Facebook developer documentation. See <a href="https://developers.facebook.com/docs/authentication/" rel="nofollow noreferrer">https://developers.facebook.com/docs/authentication/</a> for details.</p> <p>This blog post might also help with this: <a href="http://blog.theunical.com/facebook-integration/5-steps-to-publish-on-a-facebook-wall-using-php/" rel="nofollow noreferrer">http://blog.theunical.com/facebook-integration/5-steps-to-publish-on-a-facebook-wall-using-php/</a></p> <p>Here goes:</p> <pre><code>#!/usr/bin/python # coding: utf-8 import facebook import urllib import urlparse import subprocess import warnings # Hide deprecation warnings. The facebook module isn't that up-to-date (facebook.GraphAPIError). warnings.filterwarnings('ignore', category=DeprecationWarning) # Parameters of your app and the id of the profile you want to mess with. FACEBOOK_APP_ID = 'XXXXXXXXXXXXXXX' FACEBOOK_APP_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' FACEBOOK_PROFILE_ID = 'XXXXXX' # Trying to get an access token. Very awkward. oauth_args = dict(client_id = FACEBOOK_APP_ID, client_secret = FACEBOOK_APP_SECRET, grant_type = 'client_credentials') oauth_curl_cmd = ['curl', 'https://graph.facebook.com/oauth/access_token?' + urllib.urlencode(oauth_args)] oauth_response = subprocess.Popen(oauth_curl_cmd, stdout = subprocess.PIPE, stderr = subprocess.PIPE).communicate()[0] try: oauth_access_token = urlparse.parse_qs(str(oauth_response))['access_token'][0] except KeyError: print('Unable to grab an access token!') exit() facebook_graph = facebook.GraphAPI(oauth_access_token) # Try to post something on the wall. try: fb_response = facebook_graph.put_wall_post('Hello from Python', \ profile_id = FACEBOOK_PROFILE_ID) print fb_response except facebook.GraphAPIError as e: print 'Something went wrong:', e.type, e.message </code></pre> <p>Error checking on getting the token might be better but you get the idea of what to do.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload