2014-11-22 20 views
0

我想獲得我的所有關注者列表,我使用OAuth。我的代碼在這裏。 這段代碼我得到alll ID列表用逗號像如何使用php獲取twitter id的名稱

[51] => 378176058 [52] => 565040748 [53]

如何使用Twitter個人資料鏈接獲得所有followr的名字: (

<?php 
require_once('tmhOAuth.php'); 
require_once('tmhUtilities.php'); 
$profile_username = "savanpaun"; //twitter username 
$oauth_access_token = "Your access token"; //Your access token 
$oauth_access_token_secret = "Your access token secret"; //Your access token secret 
$consumer_key = "Your key"; //Your key 
$consumer_secret = "Your secret key"; //Your secret key 

$tmhOAuth = new tmhOAuth(array(
    'consumer_key' => $consumer_key, 
    'consumer_secret' => $consumer_secret, 
    'user_token' => $oauth_access_token, 
    'user_secret' => $oauth_access_token_secret, 
    'curl_ssl_verifypeer' => false 
)); 
$code = $tmhOAuth->request(
    'GET', 
    $tmhOAuth->url('1.1/friends/ids'), 
    array(
     'screen_name' => $profile_username, 
     'count' => '300' 
    ) 
); 
$response = $tmhOAuth->response['response']; 
$following_ids = json_decode($response, true); 
print_r($following_ids); 
?> 

回答

0

您要使用的users/lookup API調用

在上面的例子中,你會打電話:

https://api.twitter.com/1.1/users/lookup.json?user_id=378176058,565040748 

這將返回一個無序的列表中的所有用戶。你可以解析它來找到名字。

+0

但如何把它呢?我已經得到如[51] => 378176058 [52] => 565040748 [53] – 2014-12-05 11:59:01

+0

的結果如果你提出這個請求,你會得到'[{「id」:378176058,「id_str」:「378176058」,「name 「:」Tina Gunn「,」screen_name「:」iTinaGunn「,... – 2014-12-05 13:23:14

相關問題