[英]Filter Twitter API GET user/show results
我為Twitter API調用使用了PHP包裝器,可在此處找到。
我正在嘗試獲取我帳戶的關注者人數,並且我正在使用
$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) .....
我使用以下代碼工作
$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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.