Support » Plugin: Twitter for WordPress » [Plugin: Twitter for WordPress] Fix for Twitter Feed URL Error (code 34) since early Oct2012

Viewing 15 replies - 1 through 15 (of 21 total)
  • immanence

    (@immanence)

    I noticed my Twitter feeds go down globally across my domains sometime around 10-11 October. I looked at the time but could find no posts or blogs referring to this, so my host lost a week trying to figure out if the problem was server related. Thanks Twitter.

    Thanks for this post. It gives me a clue as to what to look for in the code of my affected domains.

    Boo to Twitter for not at least announcing this change and the affect it might have on WordPress sites.

    tallhat

    (@tallhat)

    I also had several WP sites using this plugin affected by this API issue. To be fair to Twitter they have been announcing this change for many months, probably the best part of a year. But if you’re not on a Twitter developer list of some sort the announcements may not have been seen.

    the main issue was actually that this plugin in no longer supported and hasn’t been updated for 2 years (not Twitter’s fault!).

    I’ve actually switched my themes to use newer Tweet integration plugins which are more actively developed (so hopefully less chance of this happening again in the future if the API gets changed again!)

    Thank’s to pantaluna above for the patch, but if you have the opportunity it might be better to bite the bullet and switch plugins to a more recent active one.

    immanence

    (@immanence)

    I just want to add that while I’m responding to this thread, I wasn’t using this plugin. The Twitter API change affected my themes that had Twitter feed integration as one of their featured widgets or shortcodes.

    tallhat

    (@tallhat)

    sure, i also have had the same. basically you need to be looking for the code in your widgets/plugins/shortcodes that looks something like this:

    http://twitter.com/statuses/user_timeline/username.json
    ?callback=twitterCallback2&count=5

    that’s the old API method.

    it needs to be changed to something like:

    http://api.twitter.com/1/statuses/
    user_timeline.json?screen_name=username&include_rts=true
    &count=5&callback=twitterCallback2

    see also:
    http://support.designerthemes.com/forum/topic/1832/twitter-feed-stopped-working

    leonelcamara-iam

    (@leonelcamara-iam)

    I fixed this by changing the function twitter_messages in the plugin to:

    function twitter_messages($username = '', $num = 1, $list = false, $update = true, $linked  = '#', $hyperlinks = true, $twitter_users = true, $encode_utf8 = false) {
    
    	global $twitter_options;
    	include_once(ABSPATH . WPINC . '/rss.php');
    
    	$rss= fetch_feed('http://api.twitter.com/1/statuses/user_timeline/'.$username.'.rss');
    
    	if ($list) echo '<ul class="twitter">';
    
    	if ($username == '') {
    		if ($list) echo '<li>';
    		echo 'RSS not configured';
    		if ($list) echo '</li>';
    	} else {
    			if ( is_wp_error($rss) ) {
    						if ($list) echo '<li>';
    						echo 'error retrieving feed';
    						if ($list) echo '</li>';
    			} else {
    				$messages = $rss->get_items(0, $num);
    
    				foreach ($messages as $message ) {
    					$msg = " ".substr(strstr($message->get_description(),': '), 2, strlen($message->get_description()))." ";
    
    					if($encode_utf8) {
    						$msg = utf8_encode($msg);
    					}
    					$link = $message->get_permalink();
    					if ($list)
    						echo '<li class="twitter-item">';
    					elseif ($num != 1)
    						echo '<p class="twitter-message">';
    		          	if ($hyperlinks) {
    		          		$msg = hyperlinks($msg);
    		          	}
    		          	if ($twitter_users)  {
    		          		$msg = twitter_users($msg);
    		          	}
    					if ($linked != '' || $linked != false) {
    			            if($linked == 'all')  {
    			            	$msg = '<a href="'.$link.'" class="twitter-link">'.$msg.'</a>';  // Puts a link to the status of each tweet
    			            } else {
    			            	$msg = $msg . '<a href="'.$link.'" class="twitter-link">'.$linked.'</a>'; // Puts a link to the status of each tweet
    			            }
    		          	}
    		        	echo $msg;
    		        	if($update) {
    		        	    $time = strtotime($message['pubdate']);
    		        	    if ( ( abs( time() - $time) ) < 86400 ) {
    		        	        $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
    		        		}
    		        	    else {
    		        	        $h_time = date(__('Y/m/d'), $time);
    		        	    }
    		        	    echo sprintf( __('%s', 'twitter-for-wordpress'),' <span class="twitter-timestamp"><abbr title="' . date(__('Y/m/d H:i:s'), $time) . '">' . $h_time . '</abbr></span>' );
    		        	}
    					if ($list) echo '</li>'; elseif ($num != 1) echo '</p>';
    				} /* end foreach*/
    			} /* close else */
    		}
    		if ($list) echo '</ul>';
    }

    I took the chance to fix the problem of it using a deprecated wordpress function by also changing the plugin to use fetch_feed

    Thanks leonelcamara-iam, that was very helpful! You forgot to update $message[‘pubdate’] to $message->get_date() though so it was throwing an error if the $update flag was enabled. Here’s a version with that fix:

    function twitter_messages($username = '', $num = 1, $list = false, $update = true, $linked  = '#', $hyperlinks = true, $twitter_users = true, $encode_utf8 = false) {
    
    	global $twitter_options;
    	include_once(ABSPATH . WPINC . '/rss.php');
    
    	$rss= fetch_feed('http://api.twitter.com/1/statuses/user_timeline/'.$username.'.rss');
    
    	if ($list) echo '<ul class="twitter">';
    
    	if ($username == '') {
    		if ($list) echo '<li>';
    		echo 'RSS not configured';
    		if ($list) echo '</li>';
    	} else {
    			if ( is_wp_error($rss) ) {
    						if ($list) echo '<li>';
    						echo 'No public Twitter messages';
    						if ($list) echo '</li>';
    			} else {
    				$messages = $rss->get_items(0, $num);
    
    				foreach ($messages as $message ) {
    					$msg = " ".substr(strstr($message->get_description(),': '), 2, strlen($message->get_description()))." ";
    
    					if($encode_utf8) {
    						$msg = utf8_encode($msg);
    					}
    					$link = $message->get_permalink();
    					if ($list)
    						echo '<li class="twitter-item">';
    					elseif ($num != 1)
    						echo '<p class="twitter-message">';
    		          	if ($hyperlinks) {
    		          		$msg = hyperlinks($msg);
    		          	}
    		          	if ($twitter_users)  {
    		          		$msg = twitter_users($msg);
    		          	}
    					if ($linked != '' || $linked != false) {
    			            if($linked == 'all')  {
    			            	$msg = '<a href="'.$link.'" class="twitter-link">'.$msg.'</a>';  // Puts a link to the status of each tweet
    			            } else {
    			            	$msg = $msg . '<a href="'.$link.'" class="twitter-link">'.$linked.'</a>'; // Puts a link to the status of each tweet
    			            }
    		          	}
    		        	echo $msg;
    
    		        	if($update) {
    		        	    $time = strtotime($message->get_date());
    		        	    if ( ( abs( time() - $time) ) < 86400 ) {
    		        	        $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
    		        		}
    		        	    else {
    		        	        $h_time = date(__('Y/m/d'), $time);
    		        	    }
    
    		        	    echo sprintf( __('%s', 'twitter-for-wordpress'),' <br/><span class="twitter-timestamp"><abbr title="' . date(__('Y/m/d H:i:s'), $time) . '">' . $h_time . '</abbr></span>' );
    		        	}
    					if ($list) echo '</li>';
    					elseif ($num != 1) echo '</p>';
    				} /* end foreach*/
    			} /* close else */
    		}
    		if ($list) echo '</ul>';
    	}

    phenomblue: I’ve tried using the above code, but I’m still getting the message

    No public Twitter messages

    b-summers, have you tried manually navigating to http://api.twitter.com/1/statuses/user_timeline/phenomblue.rss (replacing phenomblue with your twitter username) to see if the API call works?

    As far as I can tell it’s working:
    http://api.twitter.com/1/statuses/user_timeline/honeycombtweets.rss

    Interesting tho, I can see my tweets this morning, but not last night. Possibly my browser was cached or something.

    In any case it seems to working. Thanks for the code fix phenomblue!!!!

    And now it seems to not be working again….Odd. I haven’t changed anything since last night, and since then it’s gone from not working, to working, to not working again.

    @pantaluna
    Very thanks. I downloaded your given script, and it works.
    Hopes author update the plugin, if possible:)

    @lanjunq Thanks. I’m happy to have made a contribution!

    HI,
    Twitter has deactivated the REST API V1 https://dev.twitter.com/blog/api-v1-is-retired on Jun13,2013 so this plugin won’t work anymore.

    From now on you have to use the REST APi V1.1 and all have to be authenticated https://dev.twitter.com/docs/api/1.1/overview#Authentication_required_on_all_endpoints

    Here is an example of a page that uses the new API V1.1 : http://m.feestdagen-belgie.be/tweets.php

    @pantaluna

    Is there an easy fix? Or alternative?

    Thx
    Pjotr

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘[Plugin: Twitter for WordPress] Fix for Twitter Feed URL Error (code 34) since early Oct2012’ is closed to new replies.