2011-12-30 8 views

답변

8

https://api.twitter.com/1/users/lookup.json?screen_name=tvdw는 (내 프로필, 단지 대체 화면 이름)

또한 가능한 XML과 같이 https://api.twitter.com/1/users/lookup.xml?screen_name=tvdw

는 PHP에서 입수 API 버전 1.1에서

$data = json_decode(file_get_contents('https://api.twitter.com/1/users/lookup.json?screen_name=tvdw'), true); 
echo $data[0]['followers_count']; 
+0

덕분에, 나는 그것이 저를 허용 할 때 허용 표시됩니다. – user1117313

+0

나는 마지막 줄이 이제'echo $ data [0] [ 'followers_count']; ' – Eli

+11

API v1.0이 더 이상 작동하지 않는다고 생각한다. 이 솔루션은 더 이상 유효하지 않습니다. –

-2
<a href="https://twitter.com/twitterapi" class="twitter-follow-button" data-show-count="false" data-lang="en">Follow @twitterapi</a> 

<script> 
!function(d,s,id){ 
    var js,fjs=d.getElementsByTagName(s)[0]; 
    if(!d.getElementById(id)){ 
     js=d.createElement(s); 
     js.id=id; 
     js.src="//platform.twitter.com/widgets.js"; 
     fjs.parentNode.insertBefore(js,fjs); 
    } 
} 
(document,"script","twitter-wjs");  
</script> 

data-show-count = "true"

7

트위터 API 1.0은 더 이상 사용되지 않으며 더 이상 활성 상태가됩니다. REST 1.1 API를 사용하면 Twitter에서 데이터를 검색 할 때 oAuth 인증이 필요합니다.

사용이 대신 :

<?php 
    require_once('TwitterAPIExchange.php'); //get it from https://github.com/J7mbo/twitter-api-php 

    /** Set access tokens here - see: https://dev.twitter.com/apps/ **/ 
    $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" 
    ); 

    $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; 
?>