Automating Facebook Profile Posts

UPDATE: I refactored this into a systemd.socket-driven service, rather than a Python Flask web service. This means that the script only runs when systemd receives a request on the assigned port, saving the overhead of running a Flask service script in background full time.

I want WordPress to make a post to my Facebook profile when I publish a new WordPress post. All the WordPress plugins for Facebook use the official Facebook API which only supports posting to a Facebook page. I didn’t want that. I want my posts to go into my profile/timeline. I’ve written a hack that does what I want by using an application user interface testing tool to drive a live browser session on my workstation to make a Facebook profile post whenever I publish a new WordPress post.

Florian Domgjoni pointed the way on Python In Plain English. There he described using the Python Selenium UI test automation tool to automate a browser session to make Facebook posts. Thanks Florian!

I took Florian’s script and turned it into a Python script that is invoked upon demand by a systemd.socket service. I installed a webhooks plugin in my WordPress instance out on the internet that sends a message to that systemd service each time I publish a new WordPress post. The script then makes a corresponding post to my Facebook profile. Now it does what I want.

I’ve set up a github repo with the code and a write-up on how I set this up. Check it out if you’re interested.

dlk

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.