【问题标题】:how to get detail of all follower of twitter(not followers count) in php?如何在php中获取所有twitter关注者(不是关注者数量)的详细信息?
【发布时间】:2014-04-01 19:51:53
【问题描述】:

这里的代码可以很好地获取关注者的数量和关注。但我想向每个关注者显示所有详细信息(图片、用户名、id 等)。实际上我通过使用方法 $followingdata = json_decode( $instgram->getFollowing(20)); 我为推特做什么。

<?php


require('http.php');
require('oauth_client.php');

$client = new oauth_client_class;
$client->debug = 1;
$client->server = 'Twitter';
$client->redirect_uri = 'http://'.$_SERVER['HTTP_HOST'].
    dirname(strtok($_SERVER['REQUEST_URI'],'?')).'/login_with_twitter.php';



$client->client_id = 'my client id'; $application_line = __LINE__;
$client->client_secret = 'my client secret';

if(strlen($client->client_id) == 0
|| strlen($client->client_secret) == 0)
    die('Please go to Twitter Apps page https://dev.twitter.com/apps/new , '.
        'create an application, and in the line '.$application_line.
        ' set the client_id to Consumer key and client_secret ... '.
        'The Callback URL must be '.$client->redirect_uri);

if(($success = $client->Initialize()))
{
    if(($success = $client->Process()))
    {
        if(strlen($client->access_token))
        {
            $success = $client->CallAPI(
                     'https://api.twitter.com/1.1/account/verify_credentials.json', 
                'GET', array(), array('FailOnAccessError'=>true),   $user);
        }
    }
    $success = $client->Finalize($success);
}
if($client->exit)
    exit;
if($success)
{

$following =$user->friends_count;
$followers =$user->followers_count;
?>

【问题讨论】:

  • 你遇到了什么错误?
  • 你需要使用oauth。

标签: php twitter dreamweaver


【解决方案1】:

你可以试试这样的:

        using (WebClient client = new WebClient())
        {
            string url = "http://twitter.com/users/show.xml?screen_name=[username]";

            string response = client.DownloadString(url);
        }

问候

【讨论】:

    猜你喜欢
    • 2015-04-12
    • 2012-08-22
    • 2013-07-01
    • 2014-01-06
    • 2021-05-22
    • 1970-01-01
    • 1970-01-01
    • 2012-07-20
    • 2015-03-14
    相关资源
    最近更新 更多