Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 过滤Twitter API获取用户/显示结果_Php_Api_Twitter - Fatal编程技术网

Php 过滤Twitter API获取用户/显示结果

Php 过滤Twitter API获取用户/显示结果,php,api,twitter,Php,Api,Twitter,我正在使用一个PHP包装器来调用找到的Twitter API 我正在尝试获取我的帐户的跟随者计数,我正在使用 $url = 'https://api.twitter.com/1.1/users/show.json'; $getfield = '?screen_name=symphaticidiot'; $requestMethod = 'GET'; $twitter = new TwitterAPIExchange($settings); $response = $twitter->se

我正在使用一个PHP包装器来调用找到的Twitter API

我正在尝试获取我的帐户的跟随者计数,我正在使用

$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\u 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) .....

我用下面的代码让它工作

$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

你的意思是
echo$response[key]
?我试着使用
$response['followers\u count']
,我得到的只是一个
{
你能发布
$response
的转储吗?嗨,克里斯,谢谢你的帮助。我刚刚找到了答案。要访问json对象中的
键,你可以使用
$response->key
而不是
$response[key]。
当然了!不敢相信我错过了。