WordPress.org

Support

Support » Plugins and Hacks » Jetpack Twitter module fix for Twitter did not respond error.

Jetpack Twitter module fix for Twitter did not respond error.

  • Even in the 1.1.3 version of Jetpack, now the latest, the Twitter widget still keeps displaying the “Error: Twitter did not respond. Please wait a few minutes and refresh this page.” error. The fix is simple and I’ve included the updated section of code below. I added about 6 lines.

    if ( false === ( $tweets = get_transient( 'widget-twitter-' . $this->number ) ) ) {
    			$params = array(
    				'screen_name'=>$account, // Twitter account name
    				'trim_user'=>true, // only basic user data (slims the result)
    				'include_entities'=>false // as of Sept 2010 entities were not included in all applicable Tweets. regex still better
    			);
    
    			/**
    			 * The exclude_replies parameter filters out replies on the server. If combined with count it only filters that number of tweets (not all tweets up to the requested count)
    			 * If we are not filtering out replies then we should specify our requested tweet count
    			 */
    			if ( $hidereplies )
    				$params['exclude_replies'] = true;
    			else
    				$params['count'] = $show;
    			if ( $include_retweets )
    				$params['include_rts'] = true;
    			$twitter_json_url = esc_url_raw( 'http://api.twitter.com/1/statuses/user_timeline.json?' . http_build_query( $params ), array( 'http', 'https' ) );
    			unset( $params );
    			$response = wp_remote_get( $twitter_json_url, array( 'User-Agent' => 'WordPress.com Twitter Widget' ) );
    			$response_code = wp_remote_retrieve_response_code( $response );
    			if ( 200 == $response_code ) {
    				$tweets = wp_remote_retrieve_body( $response );
    				$tweets = json_decode( $tweets, true );
    				$expire = 900;
    				if ( !is_array( $tweets ) || isset( $tweets['error'] ) ) {
    					$tweets = 'error';
    					$expire = 300;
    				}
    				else {				
    
    					set_transient( 'widget-twitter-backup-' . $this->number, $tweets, 60*60*24 );
    
    				}
    
    			} else {
    
    				$expire = 300;
    
    				if ( false === ( $tweets = get_transient( 'widget-twitter-backup-' . $this->number ) ) )
    				{
    					$tweets = 'error';
    
    					set_transient( 'widget-twitter-response-code-' . $this->number, $response_code, $expire );
    				}
    			}
    
    			set_transient( 'widget-twitter-' . $this->number, $tweets, $expire );
    		}
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Jetpack Twitter module fix for Twitter did not respond error.’ is closed to new replies.