-
-
Save 0xnbk/576990 to your computer and use it in GitHub Desktop.
Get Your Most Recent Twitter Status (PHP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.