如何从twitter的API获取关注者的屏幕名称?
array(200) { [0]=> object(stdClass)#11 (46) { ["id"]=> int(14763734) ["id_str"]=> string(8) "14763734" ["name"]=> string(14) "Digital Trends" ["screen_name"]=> string(13) "DigitalTrends"
以下是使用亚伯拉罕API的代码
$row = $connection->get("followers/list", ["screen_name" =>
$influencer, "count" => '200', "skip_status"=>1]);
foreach($row as $data){
$handle = $data['screen_name'];
//
// echo "$handle <br /><br />";
//var_dump($data);
}
我试过
$row = json_decode($row, true);
尝试了
$data->screen_name;
似乎什么都行不通......我做错了什么?
答案 0 :(得分:1)
您需要像下面这样对一个数据执行此操作: -
foreach($row as $data){
$handle = $data[0]->screen_name;
echo "$handle <br /><br />";
}
为所有人: -
foreach($row as $data){
foreach($data as $dat){
$handle = $dat->screen_name;
echo "$handle <br /><br />";
}
}