我如何获得Twitter粉丝ID?

时间:2012-12-12 19:44:37

标签: php json twitter

点击此https://api.twitter.com/1/followers/ids.json?screen_name=USER_NAME

它返回;

{"ids":[XXXXXXXXXXX,XXXXXXXXXXXX,XXXXXXXXXXX,.........],"next_cursor":0,"next_cursor_str":"0","previous_cursor":0,"previous_cursor_str":"0"}

我怎样才能将这些ID保存在PHP上的数组中?

1 个答案:

答案 0 :(得分:1)

$data = file_get_contents("https://api.twitter.com/1/followers/ids.json?screen_name=$USER_NAME");
$array = json_decode($data, true);
if (isset($array['ids']) && is_array($array['ids']) {
    $idsArray = $array['ids'];
    var_dump($idsArray); // that is the array you need
} else {
    die('Data format error');
}