开发者

Combine multiple twitter feeds into one list with PHP?

How would I go about combining multiple users twitter feeds into one list a开发者_如何学Gond display them on my page?


You'd have to go in, I'd say, three steps :

  • Get the feed of each one of the users
    • Those are available as RSS feeds ; for example : http://twitter.com/statuses/user_timeline/17907318.rss
    • This means you can download it with curl, or download+read it with simplexml_load_file.
  • When you have downloaded the feed for each user, and parsed it, you have several arrays of feeds.
    • You'll have to merge those into a single array, containing all the feeds of all users ; see array_merge
    • And, then, probably sort that array by date ; see usort
  • And, finally, you'll have to display the resulting array, the way you want it.


As a sidenote : downloading several RSS feeds each time you want to display your resulting page is not a good idea : it will slow your site down a lot -- which means you need to put some caching mecanism in place :

  • either cache the tweets data ; for example, using a MySQL database
  • or cache the whole resulting portion of HTML code
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜