0

为什么这段代码不起作用?我需要它来获取搜索标签狗的最新推文,然后提交状态更新并回复使用搜索标签狗发送推文的用户。我正在使用亚伯拉罕的 twitteroauth,在这里找到:https ://github.com/abraham/twitteroauth/downloads

   <?php
require_once('twitteroauth.php');

define('CONSUMER_KEY', 'CONSUMERKEYHERE');
define('CONSUMER_SECRET', 'SECRET HERE');
define('ACCESS_TOKEN', 'TOKENHERE');
define('ACCESS_TOKEN_SECRET', 'TOKENSECRETHERE');

$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$twitter->host = "http://search.twitter.com/";
$search = $twitter->get('search', array('q' => 'dog', 'rpp' => 5));

$twitter->host = "https://api.twitter.com/1/";
foreach($search->results as $tweet) {
    $status = '@$tweet->from_user Here my reply would go';
    $twitter->post('statuses/update', array('status' => $status));
}
?>

我已经输入了我的消费者密钥、秘密和令牌,但在这里删除了它们。

谢谢!

4

1 回答 1

1

Twitter搜索 API独立于 REST API,不需要身份验证。所以使用 OAuth 可能行不通。

于 2011-08-05T20:46:10.667 回答