Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.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
Twitter 如何使用流式api获取转发者列表_Twitter - Fatal编程技术网

Twitter 如何使用流式api获取转发者列表

Twitter 如何使用流式api获取转发者列表,twitter,Twitter,有没有办法使用流式api获取转发者ID列表 RESTAPI有“GetStatuses/:id/retweeted_by/ids”用于获取转发者列表 流式api有一个“状态/转发”,但不是一般可用的资源 因此,我们的想法是使用“状态/过滤器”和基于推特ID的过滤器 谢谢在流媒体API返回的结果中,此处列出了转发者(如果有): $retweeters = $tweet->{'retweeted_status'}->{'activities'}->{'retweeters'}; 这

有没有办法使用流式api获取转发者ID列表

RESTAPI有“GetStatuses/:id/retweeted_by/ids”用于获取转发者列表

流式api有一个“状态/转发”,但不是一般可用的资源

因此,我们的想法是使用“状态/过滤器”和基于推特ID的过滤器


谢谢

在流媒体API返回的结果中,此处列出了转发者(如果有):

$retweeters = $tweet->{'retweeted_status'}->{'activities'}->{'retweeters'};
这里有一个页面,显示通过搜索“爱”这个词过滤的流的转发者ID——确保使用你的Twitter用户名和密码。请注意,API只返回前100个转发者

<html><body>
<?php
    echo(str_pad("START<br>",2048));
    @ob_flush();
    flush();

    $opts = array(
        'http'=>array(
            'method'    =>  "POST",
            'content'   =>  'track=love',
            'header' => "Content-Type: application/x-www-form-urlencoded\r\n"
        )
    );

    $context = stream_context_create($opts);
    $username = 'your_twitter_username';
    $password = 'your_twitter_password';
    while (1){
        $instream = fopen('http://'.$username.':'.$password.'@stream.twitter.com/1/statuses/filter.json','r' ,false, $context);
        while(! feof($instream)) {
            if(! ($line = stream_get_line($instream, 20000, "\n"))) {
                continue;
            }else{
                $tweet = json_decode($line);
                $retweeters = array();
                $retweeters = $tweet->{'retweeted_status'}->{'activities'}->{'retweeters'};

                //We store the new post in the database, to be able to read it later
                if (sizeof($retweeters) > 0) {
                    echo("<br><br>");
                    print_r($retweeters);
                }
                @ob_flush();
                flush();
            }
        }
    }
?>
</html></body>