Twitter follower count number

后端 未结 4 1615
伪装坚强ぢ
伪装坚强ぢ 2021-02-08 03:44

Is the only way to get the follower count number in plain text is using cURL? or does the twitter API provides any such option?

4条回答
  •  执笔经年
    2021-02-08 04:33

    Twitter API 1.0 is deprecated and is no longer active. With the REST 1.1 API, you need oAuth authentication to retrieve data from Twitter.

    Use this instead:

     "YOUR_OAUTH_ACCESS_TOKEN",
            'oauth_access_token_secret' => "YOUR_OAUTH_ACCESS_TOKEN_SECRET",
            'consumer_key' => "YOUR_CONSUMER_KEY",
            'consumer_secret' => "YOUR_CONSUMER_SECRET"
        );
    
        $ta_url = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
        $getfield = '?screen_name=REPLACE_ME';
        $requestMethod = 'GET';
        $twitter = new TwitterAPIExchange($settings);
        $follow_count=$twitter->setGetfield($getfield)
        ->buildOauth($ta_url, $requestMethod)
        ->performRequest();
        $data = json_decode($follow_count, true);
        $followers_count=$data[0]['user']['followers_count'];
        echo $followers_count;
    ?>
    

提交回复
热议问题