WordPress.org

Ready to get started?Download WordPress

Forums

Get Latest Tweets
Plugin error (3 posts)

  1. ted_the_bad
    Member
    Posted 3 years ago #

    Hi

    I'm getting an occasional error using the plugin. The error log from my website is as follows:

    [Tue Mar 08 21:03:22 2011] [error] [client 188.221.109.83] PHP Warning: file_get_contents(http://twitter.com/status/user_timeline/stephenfry.json) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request\r
    [Tue Mar 08 21:03:22 2011] [error] [client 188.221.109.83] in /home/sites/martyn-roberts.co.uk/public_html/cycleafrica/wordpress/wp-content/plugins/get-latest-tweets/get-latest-tweets.php on line 72

    Line 72 is:
    $json = file_get_contents($url);

    Is there any particular reason that the plugin would fail to get the information from twitter using the file_get_contents function?

    Thanks

    http://wordpress.org/extend/plugins/get-latest-tweets/

  2. ted_the_bad
    Member
    Posted 3 years ago #

    Nevermind, I found a solution.

    For anyone who may come across the same problem, change the following lines from:
    $url = "http://twitter.com/status/user_timeline/$username.json";
    $json = file_get_contents($url);
    return $json;

    to this:
    $curl_handle=curl_init();
    curl_setopt($curl_handle, CURLOPT_URL,"http://twitter.com/status/user_timeline/$username.json");
    curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Twitter');
    $json = curl_exec($curl_handle);
    curl_close($curl_handle);
    return $json;

  3. abuhaafidh
    Member
    Posted 2 years ago #

    I'm having the same problem sometimes. I've tried adding your code but this is what I got..

    R
    / over a year ago

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic