我正在为我的Twitter API调用使用PHP包装器找到here。
我正在尝试为我的帐户获取关注者数量,而我正在使用
$url = 'https://api.twitter.com/1.1/users/show.json';
$getfield = '?screen_name=symphaticidiot';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$response = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
var_dump(json_decode($response));
这样可以显示信息。如何过滤它以便它只显示follower_count
而不是
object(stdClass)#2 (43) { ["id"]=> int(391356688) ["id_str"]=> string(9) "391356688" ["name"]=> string(8) "It's Dom" ["screen_name"]=> string(14) "symphaticidiot" ["location"]=> string(13) "Hull, England" ["description"]=> string(110) "Specialised Generalist, #webguy, #poet, #IT Techie and the guy who has @amb_freeman as his amazing girlfriend." ["url"]=> string(22) "http://t.co/YSoqD2K0NZ" ["entities"]=> object(stdClass)#3 (2) { ["url"]=> object(stdClass)#4 (1) .....
答案 0 :(得分:0)
我使用以下代码
$url = 'https://api.twitter.com/1.1/users/show.json';
$getfield = '?screen_name=symphaticidiot';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$response = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
$json_output = json_decode($response);
$followers = $json_output->followers_count