【发布时间】: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