Posted By

nerdsane on 03/01/09


Tagged

curl status twitter


Versions (?)


Advertising

Website Promotion DIRECTORY is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


Who likes this?

10 people have marked this snippet as a favorite

Bluewall
dsntos
kurokikaze
rezzz
kdnewman
jackok
vali29
maxvee8
j4kp07
DrewDouglass


Get Your Most Recent Twitter Status Using PHP


Published in: PHP 






URL: http://abeautifulsite.net/notebook/75

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.

Expand | Embed | Plain Text
  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. curl_close($c);
  8. preg_match('/<text>(.*)<\/text>/', $src, $m);
  9. $status = htmlentities($m[1]);
  10. if( $hyperlinks ) $status = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $status);
  11. return($status);
  12. }
  13. ?>

Report this snippet 

You need to login to post a comment.