我目前正在使用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));
我没有得到任何结果。我的身份验证不正确吗?
答案 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>";
?>