$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$twitter->host = "https://api.twitter.com/1.1/";
$search = $twitter->get('search', array('q' => 'keyword', 'rpp' => 15));
$twitter->host = "https://api.twitter.com/1.1/";
foreach($search->results as $tweet) {
$status = 'RT @'.$tweet->from_user.' '.$tweet->text;
if(strlen($status) > 140) $status = substr($status, 0, 139);
$twitter->post('statuses/update', array('status' => $status));
}
echo "Success! Check your twitter bot for retweets!";
每次我尝试运行此脚本时都会显示
警告:为foreach()提供的参数无效