Plugin Directory

Changeset 2020281


Ignore:
Timestamp:
01/28/2019 10:08:35 AM (7 years ago)
Author:
pixelsandthings
Message:

SLight change in Src and re-arrangement of Twiiter API connection checks, now included a timeout if no connection is found.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fetch-some-tweets/trunk/fetch-some-tweets.php

    r1988966 r2020281  
    285285        $exclude_replies = $options['fst_text_field_7'];
    286286
    287         // Connect to Twitter API - https://github.com/abraham/twitteroauth
    288         $connection = new TwitterOAuth(
    289             $consumer_key,
    290             $consumer_secret,
    291             $access_token,
    292             $access_token_secret
    293         );
    294 
    295         // Verify Connection, Keys & Tokens
    296         $content = $connection->get('account/verify_credentials');
    297 
    298287        //Links, Users & Hashtags
    299288        function fst_parse_tweet( $text ){
     
    315304        }
    316305
     306        // Connect to Twitter API - https://github.com/abraham/twitteroauth
     307        $connection = new TwitterOAuth(
     308            $consumer_key,
     309            $consumer_secret,
     310            $access_token,
     311            $access_token_secret
     312        );
     313
     314        // Verify Connection, Keys & Tokens
     315        $content = $connection->get('account/verify_credentials');
     316
     317        // Verifyk Connection to Twitter
     318        if( isset( $content ) ){
     319
     320            $tweet_user_timeline = '<section class="no-tweets no-connection">';
     321            $tweet_user_timeline .= '<p>Cannot connect to Twitter, check your internet!</p>';
     322            $tweet_user_timeline .= '</section>';
     323            return $tweet_user_timeline;
     324            die();
     325
    317326        // Check for Errors - $content
    318         if( isset( $content->errors ) ){
     327        } elseif( isset( $content->errors ) ){
    319328
    320329            // No Tweets
     
    323332            $tweet_user_timeline .= '</section>';
    324333            return $tweet_user_timeline;
    325             //die();
     334            die();
    326335
    327336        } else {
     
    407416                                // Tweet Type - Tweet, Retweet, Quoted Retweet or Reply
    408417                                if( $retweet ){
    409                                     $tweet_user_timeline .= '<span class="tweet-type">Retweet</span>';
     418                                    $tweet_user_timeline .= '<span class="tweet-type">Retweet</span> - ';
    410419                                } elseif( $quoted_retweet ){
    411                                     $tweet_user_timeline .= '<span class="tweet-type">Quoted Retweet</span>';
     420                                    $tweet_user_timeline .= '<span class="tweet-type">Quoted Retweet</span> - ';
    412421                                } elseif( $reply ){
    413                                     $tweet_user_timeline .= '<span class="tweet-type">Reply</span>';
     422                                    $tweet_user_timeline .= '<span class="tweet-type">Reply</span> - ';
    414423                                } else {
    415                                     $tweet_user_timeline .= '<span class="tweet-type">Tweet</span>';
     424                                    $tweet_user_timeline .= '<span class="tweet-type">Tweet</span> - ';
    416425                                }
    417426
    418                                 $tweet_user_timeline .= '<span class="tweet-date"> - ';
     427                                $tweet_user_timeline .= '<span class="tweet-date">';
    419428                                $tweet_user_timeline .= fst_parse_date( $tweet_date );
    420429                                $tweet_user_timeline .= '</span>';
Note: See TracChangeset for help on using the changeset viewer.