使用PHP获取您最近的Twitter状态

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用PHP获取您最近的Twitter状态相关的知识,希望对你有一定的参考价值。

To find your numerical Twitter ID, login to Twitter and click on your RSS feed (bottom of the page). The URL will look something like http://twitter.com/statuses/friends_timeline/12345678.rss. Your ID will be the 12345678.
  1. <?php
  2. function get_status($twitter_id, $hyperlinks = true) {
  3. $c = curl_init();
  4. curl_setopt($c, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/$twitter_id.xml?count=1");
  5. curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  6. $src = curl_exec($c);
  7. preg_match('/<text>(.*)</text>/', $src, $m);
  8. $status = htmlentities($m[1]);
  9. if( $hyperlinks ) $status = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href="\0">\0</a>", $status);
  10. return($status);
  11. }
  12. ?>

以上是关于使用PHP获取您最近的Twitter状态的主要内容,如果未能解决你的问题,请参考以下文章