Managing Feeds with Feedburner API

Nate posted on the CF-talk e-mail list today about managing feeds on Feedburner. If you read Ray Camdens blog you would have seen his post about how you can return stats from Feeburner on a feed. Ray also provided a Feedburner.cfc to wrap the API.

But what if you wanted to actually manage your feeds?

Well I spent a little time wrapping the Feedburner Management API into a Coldfusion Component. It's not quite 100% complete as I have not implemented the modify or resync methods but I have attached what I have thus far to download.

It's relatively simple to use.

<!--- instantiate the object replacing username and password with actual username and password --->
<cfset myFeedObj = createobject("component","com.gg.feedburner").init(username,password)>
<!--- returns an array of structures containing uri,id, and feed title --->
<cfset myfeeds=myFeedobj.findfeeds()>
<cfdump var="#myfeeds#">

Here is the resulting dump (I only have one feed on Feedburner):

Once you have that array you can get additional information on a feed by calling the getFeed function.

<cfset feedDetails = myFeedObj.getfeed(id=myffeds[1].id)>
This results in the following:

To Add a feed its a bit more complicated but still relatively easy.

<cfset services = arrayNew(1)>
<cfset servicesStruct= structNew()>
<cfset servicesStruct.class="BrowserFriendly">
<cfset servicesStruct.params = arrayNew(1)>
<cfset servicesStruct.params[1]=structNew()>
<cfset servicesStruct.params[1].paramname='forceLandingPage'>
<cfset servicesStruct.params[1].paramvalue='true'>
<cfset t = arrayAppend(services,servicesstruct)>
<cfset myfeed =myFeedobj.addFeed('garyrgilbert2','testfeed','http://www.garyrgilbert.com/blog/rss.cfm?mode=full',services)>
<cfdump var="#myfeed#">

On a successful call you would get a structure back with the id, uri, and title of the feed. An unsuccessful call would return a structure with the aforementioned values empty an an additional structure key of error indicating the error returned from the api.

Deleting a feed using the CFC is also dead easy.

<cfset myfeed =myobj.deleteFeed(uri='garyrgilbert2')>

Here you get a true if it deleted the feed or a false otherwise.

Happy Coding...

Comments