Twitter OAuth发送状态更新不起作用

时间:2011-08-05 20:39:30

标签: php twitter oauth status reply

为什么这段代码不起作用?我需要它来获取搜索标签狗的最新推文,然后提交状态更新,并回复发送带有搜索标签狗的推文的用户。我正在使用亚伯拉罕的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));
}
?>

我输入了我的消费者密钥,密码和令牌,但在此处删除了它们。

谢谢!

1 个答案:

答案 0 :(得分:1)

Twitter search API与REST API分开,不需要身份验证。所以使用OAuth可能不会起作用。