Twitter Api 1.1响应为{"error ":[{"message":


Twitter Api 1.1 response as {"errors":[{"message":"Could not authenticate you","code":32}]}

我想在我的网页整合推特用户时间线。为此,我使用以下库TwitterAPIExchange.php (https://github.com/J7mbo/twitter-api-php)

在index.php文件中,我已经正确地提供了所有必需的键。

无论我尝试运行Index.php,我得到{"errors":[{"message":"Could not authenticate you","code":32}]}错误,我不知道如何解决它。

我正在使用get方法来获取数据。

下面是index.php代码:

ini_set('display_errors', 1);
require_once('TwitterAPIExchange.php');
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
'oauth_access_token' => "xxxxxxxxxxxxxx",
'oauth_access_token_secret' => "xxxxxxxxxxxxxxxxxxxx",
'consumer_key' => "xxxxxxxxxxxxxx",
'consumer_secret' => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
);

/** Perform a GET request and echo the response **/
/** Note: Set the GET field BEFORE calling buildOauth(); **/
$url = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
$getfield = '?screen_name=fresherworld';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
         ->buildOauth($url, $requestMethod)
         ->performRequest();

我没有看到任何错误在你的代码。但是要检查一下。1)检查你的twitter应用权限,设置为读,写,2)尝试重新生成您的消费者密钥/秘密。3)用户是否批准了你的应用,你只能看到那些批准了你的应用的用户详细信息。4)使用最新的库。