views:

141

answers:

1

I want to calculate the number of Tweets of a Twitter Search, and a countup. Just like GigaTweet. How can I calculate this using PHP and the Twitter API?

+1  A: 

There are plenty of documents and PHP libraries out there to assist you with this:

As for the specific method I would use: - http://apiwiki.twitter.com/Twitter-Search-API-Method:-search

Example: - http://search.twitter.com/search.atom?q=twitter

I would then use simplexml (http://www.php.net/simplexml) to parse the atom feed. From there I would use the count method to get the number of "entry" items in that feed.

Please keep in mind that the atom format uses xml namespaces and you'll have to use the children method to retrieve items correctly. More on this can be found here: http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/

Levi Hackwith