Hi everyone, I got the code below from this site http://upshots.org/php/php-get-tweets:
Code:
<?php
$user = 'galileedetroit';
$uri = "http://twitter.com/statuses/user_timeline/{$user}.json?count=1";
$raw = file_get_contents($uri);
$data = json_decode($raw);
$tweet = end($data);
$html = $tweet->text;
$trimmed = trim($html);
$linked = preg_replace('/(https?:\/\/\S+)/', '<a target="_blank" href="\1">\1</a>', $trimmed);
print $linked;
?>
For some reason, I keep getting the following error:
Warning: end() expects parameter 1 to be array, null given in C:\vhosts\galileedetroit\index2.php on line 52
I am working on a local server. Don't have access to my remote right now. Is this one of those things that just won't work locally? Sorry to sound stupid, but I don't really mess with PHP. I am digging on JavaScript right now, but I really want to use PHP for this because the JavaScript equivalent is causing script conflicts that I don't feel are going to get any better any time soon (and I'm tired of effing with it
).
Thanks!
Bookmarks