Skip to content

Instantly share code, notes, and snippets.

@0xnbk
Created September 13, 2010 08:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xnbk/576990 to your computer and use it in GitHub Desktop.
Save 0xnbk/576990 to your computer and use it in GitHub Desktop.
Get Your Most Recent Twitter Status (PHP)
<?php
function get_status($twitter_id, $hyperlinks = true) {
$c = curl_init();
curl_setopt($c, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/$twitter_id.xml?count=1");
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$src = curl_exec($c);
curl_close($c);
preg_match('/<text>(.*)<\/text>/', $src, $m);
$status = htmlentities($m[1]);
if( $hyperlinks ) $status = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $status);
return($status);
}
?>
@0xnbk
Copy link
Author

0xnbk commented Sep 13, 2010

Get Your Most Recent Twitter Status (PHP)

A simple PHP function that get your latest Twitter status so you can display it on your blog or website.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment