
Automatic blog posts from your Google Reader Shared items
September 9, 2007You may notice every once in a while I have a post titled “items from” and some date, with the content being some (hopefully) interesting items I’ve read on the web that day. Creating that post looks like a simple matter of manually creating a new post, copying and pasting the title and a summary, then adding some formatting and publishing. While that isn’t too hard, even easier would be if you could just share interesting items in your Google Reader (using the “Share” link) during the day and have them magically appear later that night in your blog.
Below is a Ruby script I wrote that does just that. It consumes an Atom feed of your Google Reader Shared Items, formats them, and automatically posts them to your WordPress blog using their XML-RPC interface. You can run this manually, or schedule it to run at a specific time as a cron job. Note that this does not rely on inserting the post directly into the WordPress SQL tables as I’ve seen other WP plug-ins do – that requires you to have access to the WP database, which you don’t if (like me) your blog is hosted at wordpress.com.
This whole process takes less than 100 lines of Ruby, including lot’s of comments. What this shows is how easy it is to “glue” together different web services to accomplish a useful goal when all the players use well documented web standards. It also shows how simple, yet powerful, a dynamic scripting language designed for the web can be.
The script can be found here. Read the comments at the very top for examples of how to run it. Make sure you edit your personal settings in the “Stuff you should change” section.
Later, I’ll show you a similar script that automatically creates blog posts from your del.icio.us links.






[...] 2007 Similar to the way I wanted to share my Google Reader Shared items on my blog (that post is here), I also decided I wanted to share some of my del.icio.us bookmarks. If you aren’t familiar [...]
[...] Automatic blog posts from your Google Reader Shared items « Tzetze Fly – by Dan Woolley – Below is a Ruby script I wrote that does just that. It consumes an Atom feed of your Google Reader Shared Items, formats them, and automatically posts them to your WordPress blog using their XML-RPC interface [...]
where can I get this script?
@Warner – The post has a link to the script – ‘The script can be found here’ – click on the word ‘here’ and you’ll see the script.
Hi,
I just tried your script and it’s working perfectly.
Very nicely done and thanks for sharing.
P.S. due to my noob-ness I was getting an hostname error, until I removed the http:// part from the blogurl. Maybe other non-coders will find this info useful.
Thanks again!
where do you post the ruby script? in google? in my blog? where in my blog? Great concept! I hope i can get it to work
Josh – This is a Ruby script that will run from your command line, similar to running a perl script, shell script, or batch file. If you are running Mac OSX or Linux, you probably already have Ruby installed and this script can be run with a simple ‘Ruby posttogooglereader.rb’. If you are running Windows, you will need to install Ruby first. You can download Ruby from http://www.ruby-lang.org.
I have been looking out a way to incorporate my google reader shared items on a blog in wordpress.com . I think i have reached the apt place where i have got a solution to this problem.
As i am not a very tech person, i am not able to understand the procedure to use this script and get the maximum out of it. Now, you have told “Read the comments at the very top for examples of how to run it. Make sure you edit your personal settings in the “Stuff you should change” section.” .
Where are the examples you are mentioning?
What should i do after i install ruby?
Can you explain the procedure…
Thank you.
1. Install ruby. If you are using OSX, you already have ruby installed.
2. Download the script using the link above and name it ‘postfromgooglereader.rb’.
3. Inside the script, edit the section ‘Stuff you should change’ near the top. You will need to define your blog url, id, and password on the lines indicated. Then you need to define your google reader share url, which is a little harder so there’s some more specific instructions there.
4. Run the script at your command line by typing ‘ruby postfromgooglereader.rb’. This will get google reader items back 1 day and make them drafts in your WordPress blog. You can use parameters to adjust those last two values: ‘test’ does not post to your blog, ‘draft’ posts as drafts, and ‘live’ posts right to your live blog; a number indicates how many days back to go. So ‘ruby postfromgooglereader.rb live 10′ would post live to your blog all google reader shared items in the past 10 days.
Hi Dan, Thanks for the elaborate procedure. To an extent i could help myself with the procedure, but when i am trying to run it it is generating some errors.
I have posted a screen shot of the error here : http://kinkynews.files.wordpress.com/2008/11/warning.jpg
Can you please help me in sorting this out. It will be a great help , if you could. I am sorry my understanding of these concepts are very minimal.
Once again thanks a lot for the elaborate procedure.
Ahhhhh yes – missed a step. See that “require ‘feed_tools’” toward the top of the script? Those are gems that the script relies on and that’s the error message you’re getting. To install that, go to the command prompt and type “gem install feedtools” – in Linux or OSX you may need to “sudo gem install feedtools”. That should install smoothly, then try running the script again.
Thanks for making me understand the intricacies involved in this process. i did try installing gem feedtools by typing gem install feedtools but it gives me couple of errors, which i searched on google to resolve but in vain.(I did wreck my head over it, but…) I am posting another screen shot of the error i encountered while trying this.
http://kinkynews.files.wordpress.com/2008/11/e2.jpg
It will be great if you could help me with also. Its just that i am too bad at these stuff. I wish this is the last time, i am going to bug you for debugging my problems.
Thanking you.
It looks like gem doesn’t have rubyforge as a repository, so it doesn’t know how to get feedtools downloaded. Try running ‘gem sources -a http://gems.rubyforge.org/‘ to add rubyforge as a source repo, then try your ‘gem install feedtools’ again.