简体   繁体   English

如何使用PHP从Twitter ID获取名称

[英]How to get name from twitter id with php

I want to get my all follower's list, i uses OAuth. 我想获取所有关注者的列表,我使用OAuth。 my code is here. 我的代码在这里。 by this code i get alll id list with comma like 通过此代码,我用逗号获得alll id列表,例如

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

how to get all followr's name with twitter profile link :( 如何通过Twitter个人资料链接获取所有关注者的名字:(

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

You want to use the users/lookup API call. 您要使用用户/查找 API调用。

In the above example, you would call: 在上面的示例中,您将调用:

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

That will return an unordered list of all the users. 这将返回所有用户的无序列表。 You can parse it to find the names. 您可以解析它以找到名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM