我正在设置测试机器人,以便从我的用户状态/ mentions_timeline转发推文。 我真的需要一些帮助来从脚本创建的提及数组中获取状态ID,以便我可以使用statususes / retweet /:id资源然后转发提及
这里是代码,我不会包含Auth代币,但它们在那里,我发布状态更新没有问题。
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$twitter->host = "https://api.twitter.com/1.1/";
$tweets = $twitter->get('statuses/mentions_timeline', ['count' => 200]);
$tweets1 = $twitter->get('users/show', ['count' => 170]);
$totalTweets[] = $tweets;
$page = 0;
$twitter->host = "https://api.twitter.com/1.1/";
for($count = 20; $count < 21; $count += 20) {
$max = count($totalTweets[$page]) - 1;
$tweets = $twitter->get('statuses/mentions_timeline', ['count' => 20, 'max_id' => $totalTweets[$page][$max]->id_str, 'screen_name' => 'UnkindRTs', 'include_rts' => false]);
$totalTweets[] = $tweets;
$page += 1;
}
$twitter->host = "https://api.twitter.com/1.1/";
$start = 1;
foreach($totalTweets as $page) {
foreach($page as $key){
echo $start . ':' . $key->text . '<br>';
$postconn = $twitter->post('statuses/retweet/'.$key->text.id_str);
$start++;
}
}
&#13;
答案 0 :(得分:0)
尽管如此,我还是想出了所有的帮助! XD
改变 $ postconn to
$postconn = $twitter->post('statuses/retweet/'.$key->id_str);
只有一个小错误xD