Cross-Poster for Movable Type
By now, the traditional use of feeds as a form of content syndication is beginning to look somewhat old-fashioned. But fear not: here’s a use that is as traditional as can be.
I needed a script to check all of the weblogs I write for and to cross-post everything I write onto my own weblog. Bear in mind that I’m not the only author on these other sites.
To do this, check their RSS feeds on a set schedule, grab the content within, build a big entry, and then post it. This code is for a Movable Type installation, but it isn’t hard to modify it to fit another weblogging platform.
Walking Through the Code
You open the proceedings by defining all of the libraries and modules. This is the exact same code as I have running on my own server, so you need to modify the following paths to point to your own Movable Type libraries, blog IDs, and so on:
use lib "/web/script/ben/mediacooperative.com/lib"; use lib "/web/script/ben/mediacooperative.com/extlib"; use lib "/web/script/ben/lib/perl"; use MT; use MT::Entry; use Date::Manip; use LWP::Simple 'get'; use XML::RSS; my $MTauthor = "1"; my $MTblogID = "3"; my $MTconfig = "/home/ben/web/mediacooperative.com/mt.cfg"; my $guts = "";
Now, let’s set up a list of sites to check. For each
site, you need to define only the feed URL and the
<dc:creator>
or
<author>
name under which I am posting.
Everything else you can get from the feed itself. For example:
http://del.icio.us/rss/bhammersley “bhammersley” http://www.oreillynet.com/feeds/author/?x-au=909 ... |
Get Developing Feeds with RSS and Atom now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.