Skip to content

Instantly share code, notes, and snippets.

@knorthfield
Created March 29, 2012 10:53
Show Gist options
  • Save knorthfield/2235828 to your computer and use it in GitHub Desktop.
Save knorthfield/2235828 to your computer and use it in GitHub Desktop.
Use PHP to get latest tweet for user
<?php
$twitter = json_decode(
file_get_contents(
'http://twitter.com/users/show/smythsonsdeli.json',
false,
stream_context_create(
array(
'http' => array('ignore_errors' => true)
)
)
),
true
);
$latest_tweet = preg_replace(
'#(?<![a-z0-9>])@(\w+)\b#i',
'<a href="http://twitter.com/\1">@\1</a>',
$twitter['status']['text']
);
echo $latest_tweet;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment