Twitter oauth搜索无法正常工作

时间:2014-03-23 17:48:07

标签: php twitter twitter-oauth

我目前正在使用twitteroath库https://github.com/abraham/twitteroauth来搜索推文。

这是我的代码:

 require_once('twitteroauth.php');

 function getConnectionWithAccessToken($oauth_token, $oauth_token_secret) {
 $connection = new TwitterOAuth(X, Y,       $oauth_token, $oauth_token_secret);
 return $connection;
}

$connection = getConnectionWithAccessToken(Z, K);

$author = "cosmopoulos";

$response = $connection->get('search/tweets', array('q' => $author));

我没有得到任何结果。我的身份验证不正确吗?

1 个答案:

答案 0 :(得分:0)

试试这个,

<?php
require_once('twitteroauth/twitteroauth.php');
include('config.php');
$connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $ACCESS_TOKEN , $ACCESS_SECRET);
$content = $connection->get('account/verify_credentials');
$author = "cosmopoulos";
$tweets = $connection->get("search/tweets", array("q" => $author));
echo "<pre>";
var_dump($tweets);
echo "</pre>";
?>