Twitter REST API v1.1 update fix for Garee’s Twitter Stream

Since Twitter shut down the old 1.0 API many of us using Twitter plug-ins found ourselves on Twitter’s developer page trying to figure out how to fix our website feeds. I use Garee’s Twitter Stream for a lot of my clients and all of their feeds broke. After doing some reading, I needed a quick fix and I’m not that great of developer to fix the plugin in one day. Instead, I’ve found a plugin that adds the proper functions globally to wordpress and made the changes to Garee’s Twitter Stream to get it working again. If you’re looking to just get a quick fix here’s how you can do it:

First, go to http://dev.twitter.com, make sure you have an account and then go to My Applications in the top right after mousing over on your photo to get a drop down menu. Click Create a New Application, fill out the information (you can leave Callback URL) and create your application. Once you’re done click the Create my Access Token button to get your access token. You may have to refresh to get it to show.

Now go back to your wordpress back-end and install the oAuth Twitter Feed for Developers. Now go to the settings page for that plugin and fill in all your token information. From there you now need to make the changes to Garee’s Twitter feed. You can go your Plugin Editor and edit garees_twitter_stream.php from the back end or do it in your own text editor. You can just copy and paste my code here.

Otherwise, here’s the fix I applied:

At line 200 replace

//$stream = wp_remote_fopen($query);
 
//print_r(json_decode($stream, true));
 
$cache_name = "garee" . md5($query);
 
if ( false === ( $tweets = get_transient( $cache_name ) ) ) {
$data['origin'] = "query";
 
$stream = wp_remote_fopen($query);
if (strstr($stream,'{"error":"Rate limit exceeded')) // detect {"error":"Rate limit exceeded. Clients may not make more than 150 requests per hour.","request":"\/statuses\/show\/29640123173.json"}
return garees_twitter_stream_error("Rate limit exceeded! (check your cache-time-setting)");
 
$tweets = garees_twitter_stream_filter($stream);
//$stream = "test";
unset($stream);
set_transient($cache_name, $tweets, 60*$cache_time );
} else {
$data['origin'] = "cache";
}

 

with this

// calls stormTwitter class to gather tweets using Twitter's REST 1.1 format.
$stream = getTweets($count, $user, array('trim_user'=>false, 'exclude_replies'=>true, 'include_rts'=>false));
$tweets = garees_twitter_stream_filter($stream);

and then at line 244 replace:

$tweets = json_decode($stream, true);

with

$tweets = $stream;

And that’s it! Your feed should be working again. You do not have to make any changes to your widget.

2 Responses to Twitter REST API v1.1 update fix for Garee’s Twitter Stream

  • Bohnna: Thanks a ton for sharing this. I had the same problem you did with Garees Twitter Stream not functioning. So, I applied the fix you outlined above and am getting this error from WordPress when I try to update the plugin code:

    Parse error: syntax error, unexpected ‘=’, expecting ‘)’ in /var/www/pvpost.com/wp-content/plugins/garees-twitter-stream/garees_twitter_stream.php on line 201

    Any suggestions?

    Reply
    • Bohnna Chhim

      Jay, I apologize for not getting back sooner. Garee has updated this plugin so you no longer need the fix. But I’m sure you have figured that all out by now. Best wishes!

      Reply
  • Leave a Reply

    Your email address will not be published. Required fields are marked *