SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast gilmeragency's Avatar
    Join Date
    Oct 2012
    Location
    Palm Springs, CA
    Posts
    34
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Get Latest Tweet

    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: file_get_contents(http://twitter.com/statuses/user_tim...json?count=1): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in C:\vhosts\galileedetroit\index2.php on line 50
    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!

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,285
    Mentioned
    181 Post(s)
    Tagged
    4 Thread(s)
    You can find the answer to your question by visiting that URL in a browser:
    {"errors":[{"message":"Sorry, that page does not exist","code":34}]}
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •