SitePoint Sponsor

User Tag List

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

    Get Latest Tweet

    Hi everyone, I got the code below from this site

    $user = 'galileedetroit';
    $uri = "{$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( 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 ).


  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Central Florida
    192 Post(s)
    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)

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


Posting Permissions

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