Posting to Facebook using Python
In relation to my post, Trolling For Self Promotion, I have begun investigating utilizing the Facebook Graph API to post messages.
I found a GREAT reference article that walks through the steps necessary to post to Facebook: http://nodotcom.org/python-facebook-tutorial.html
In order to prevent spam (which makes sense, although this is what we want to do), the API only lets a user post messages to the user's own wall.
Here are some references:
- https://developers.facebook.com/docs/sharing/reference/feed-dialog
- http://stackoverflow.com/questions/15427355/facebook-graph-api-post-to-friends-timeline-issue
We cannot use Facebook's API to post to other people's walls, but this does not mean we are blocked from accomplishing our goal! I have some ideas on how Selenium could be leveraged to accomplish the same task.
Facebook Example
Even though the task I set out to do was not possible, I learned a lot and have a great zero to one example on how to post to a page.
Per Nikhil's blog, I created a Page: https://www.facebook.com/DEV3LOPER/
I then created a GitHub project to post to a page: https://github.com/DEV3L/python-facebook-api-example
With the right configuration (access token + page id), I was able to post a "Hello, world!" message.
To be fun, I looked up a sentence generator, and leveraged that to create a few sentences from the transcript of Anchorman and Romeo and Juliet combined.
I will find a better sentence generator and content someday!
Get In Touch
We'd love to hear from you! Whether you have a question about our services, need a consultation, or just want to connect, our team is here to help. Reach out to us through the form, or contact us directly via social media.