Technology

Ning: Retrieve and Format API Queries

This weekend I was working on a project where we wanted to pull content from all over Smaller Indiana (built with Ning) into a central page. The Indianapolis Fringe Festival is full swing and Smaller Indiana wanted to help promote the event.

Ning’s API isn’t the most organized, and the documents and sample applications are really lacking. Because of time constraints to get the page up and running, I had to take some short cuts rather than built out a proper solution. The current page works, but it’s hard coded without much flexibility. There could probably be some additional validation of the content as well (example: ensuring blog urls are formatted differently from forum urls, etc.).

The way Ning’s API works is that it’s pretty much a querying engine where you can get the results you need in an RSS feed. We requested that anyone who blogs, starts a discussion, or uploads photos specially tag their content with indyfringe-2008. This allows me to built a custom feed address that retrieves all of the content (in descending order by published date with the following URL:

http://smallerindiana.ning.com
/xn/atom/1.0/tag(value=%27indyfringe-2008%27)/[email protected]

Within the page, I then extract and organize the data on the page using the Magpie RSS Class for PHP. Click to zoom in on the code or you can view or download it.

API and Format it” width=”300″ height=”159″ class=”aligncenter size-medium wp-image-2694″ />

There’s some interesting functionality here. Thanks to Tyler Ingram (from my high school home of Vancouver!) who assisted with formatting the dates correctly via Twitter.

Once again, it’s not the cleanest code and it’s also not broken up properly into functions for quick use – but it works. 🙂 I replace the links so the urls are properly directed, I remove any HTML tags from the included content, I format the date, and I limit the number of words displayed so that the page result looks like this:

Some Babble on the Babbling Banshee Like with my review of Good Grief, Sidney there were bits to like and bits not… 8/24 11:55 AM

This API is a huge benefit because you can actually subscribe to content and topics in Ning networks that are specifically tagged, or you can integrate an external website with Ning content. I just hope that Ning works on the sample applications and documentation so folks like me can do this without spending so much time!

Leave a Reply