Facebook to WordPress

facebook_to_wordpress.py is a script that copies your Facebook posts to a WordPress blog of your choice. It helps you take control over your posts, pictures, and other online memories, following in the spirit of the Indie Web movement.

I’ve used it to copy a number of my own Facebook posts to this web site. Here are a few examples:

The script reads one or more Facebook posts in Graph API JSON format and publishes them to a WordPress blog via XML-RPC. It includes and formats pictures, locations (ie checkins), links, tagged people, comments, and a link back to the original post.

To get the JSON for your Facebook posts, click on this Graph API Explorer link, copy all of the text in the big bottom right pane into a file, then run facebook_to_wordpress.py on that file.

If you see a (right arrow) next to posts on the left side, that means you have more posts. Click on the arrow, copy the new text into another file, run facebook_to_wordpress.py on that new file, and repeat until the arrow disappears.

Example usage:

$ ./facebook_to_wordpress.py http://myblog.com/xmlrpc.php \
    user password < posts.json
Reading posts from stdin
Connecting to http://myblog.com/xmlrpc.php as user
Skipping 2012-11-06
Downloading https://fbcdn-photos-a.akamaihd.net/hphotos-ak-prn1/58835_10100411291505323_408284397_o.jpg
Uploading as image/jpeg
Publishing pumpkin carving
Publishing comment "http://cdn.smosh.com/sites/def"
Updating comment's time to 2012-10-29 02:51:31
Publishing comment "oh my god that's good"
Updating comment's time to 2012-10-29 05:43:45
Skipping 2012-10-28

Facebook also lets you download your data as a set of HTML pages and images in a zip file. It’s not as useful for publishing on the web, but if you just want an archive of your data, or if you want to publish it as static, read-only pages, it’s an option.

This script could be expanded to download your posts from Facebook automatically, and even converted to a webapp. It’s also a good starting point for doing the same thing for Twitter, Google+, and similar social networks. I don’t plan to do any of that in the near future, but I’m happy to help anyone else who wants to!


2 thoughts on “Facebook to WordPress

Comments are closed.