2016-09-12 8 views
0

TwitterAPIExchange APIを使用してTwitterで次の合計数を取得しますが、結果には次のデータは含まれません。 どうすればいいですか?TwitterのAPIは表示されません

followers_countとfriends_countは使用できますが、follow_countでは使用できません。

答えて

0

あなたはフォロアカウンターのための次のコードを使用することができます。

<?php 
    $xml_data = new SimpleXMLElement(urlencode(strip_tags('https://twitter.com/users/google.xml')), null, true); 
    echo "Follower count: ".$xml_data->followers_count; 
?> 

・ホープ、このことができます:あなたは次のコードを使用することができますxml形式にデータを解析するための

<?php 


    require_once('TwitterAPIExchange.php'); //https://github.com/J7mbo/twitter-api-php 

    /** Access token (https://dev.twitter.com/apps/) **/ 

    $access_token_settings = array(
      'oauth_access_token' => "YOUR_OAUTH_ACCESS_TOKEN", 
      'oauth_access_token_secret' => "YOUR_OAUTH_ACCESS_TOKEN_SECRET", 
      'consumer_key' => "YOUR_CONSUMER_KEY", 
      'consumer_secret' => "YOUR_CONSUMER_SECRET" 
    ); 

    $twitter_api_url = 'https://api.twitter.com/1.1/statuses/user_timeline.json'; 
    $getfield = '?screen_name=YOUR SCREEN NAME'; 
    $requestMethod = 'GET'; 
    $twitter = new TwitterAPIExchange($access_token_settings); 
    $follow_count=$twitter->setGetfield($getfield)->buildOauth($twitter_api_url, $requestMethod)->performRequest(); 
    $data = json_decode($follow_count, true); 
    $followers_count=$data[0]['user']['followers_count']; 
    echo $followers_count; 
?> 

を。

+0

フォローしていないカウントをカウントしたい – SCC

関連する問題