Post to Facebook with Python

Let’s take a quick look at a great tool to post to Facebook from Python called fbconsole. It’s fairly self explanatory, so I won’t bother going into much textual detail here. I’ll take you through some of the basic features and highlight as we go. In the following code snippet, we will post some data to our personal status feed, similar to how we push from KindleQuotes to Facebook when a user would like to share an item.

import fbconsole as F

# If you have an APP ID from Facebook, you can add that here.
# Otherwise, you will be posting as fbconsole.
F.APP_ID = '<YOURID>'

# Set some authentication parameters
# Here we will set the ability to publish to a stream
F.AUTH_SCOPE = ['publish_stream']

# Now we will login and get our OAuth token.
F.authenticate()

# After successful login, we can add our status update.
# Let's assume we have some neat data we want to push to the stream.
# We'll post our world_changing_data to our personal feed
F.post('/me/feed', {'message': world_changing_data})

# Want to logout and wipe your OAuth token?
F.logout()

We just completed a very simple data push to our Facebook status feed from within our python program. There is a lot more functionality to check out once you have the basic setup working in your program.