开发者

Calculate the number of Tweets in PHP

I want to calculate the number of Tweets of a Twitter Search, and a countup. Just like GigaTweet. How can I calcul开发者_如何学Goate this using PHP and the Twitter API?


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

  • http://apiwiki.twitter.com/Libraries#PHP
  • http://apiwiki.twitter.com/Twitter-API-Documentation

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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜