Python Chronicles: Updating FB Status using Python & GraphAPI

So, while I was exploring the infinite possibilities presented by Python. I found this great python package facepy. Using which you can update your facebook status from python terminal. The only prerequisite is that you must be facebook developer to gain access to GraphAPI. Following the steps given below, you can also update your status using python:

1. Download facepy and install it by running this command:

     python setup install


2. Create a new application or use an existing one previously created.

3. Run python.exe from command terminal (cmd in Windows). Use the user access token created in the previous step with facepy:

>>from facepy import GraphAPI

>>ACCESS_TOKEN = 'access-token-copied-from-graph-api-explorer-on-web-browser'

>>graph = GraphAPI(ACCESS_TOKEN)
>>graph.post('me/feed', message='Hello World!')


That's it. You may further experiment with GraphAPI using facepy.

Happy Experimenting!!

MG

Comments

  1. graph.post('me/feed', message='Hello World!')

    I am getting Error : OAuthError: [200] (#200) The user hasn't authorized the application to perform this action

    ReplyDelete
  2. But Graph.get('me/posts') this is working fine

    ReplyDelete
  3. I think Facebook must have updated their API. I'll check and update the article accordingly. Thanks for the comment and pointing out the error.

    ReplyDelete

Post a Comment

Popular posts from this blog

Project Wild Penguin 12.4.2017: Installing Broadcom Wireless Drivers to connect to JBL Bluetooth Speaker on Xubuntu 16.10

Project Wild Penguin 22.4.2017: To delete directories inside current directory whose contents are less than a given size

ANPR Project Day 1: Standard Format of Indian Number Plate