【问题标题】:Twitter Api 1.1 response as {"errors":[{"message":"Could not authenticate you","code":32}]}Twitter Api 1.1 响应为 {"errors":[{"message":"Could not authenticate you","code":32}]}
【发布时间】:2016-01-22 00:22:32
【问题描述】:

我想在我的网页中集成 Twitter 用户时间线。为此我正在使用以下库 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();

【问题讨论】:

    标签: php twitter


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2013-07-29
      • 2017-11-19
      • 2015-08-26
      • 2014-05-06
      • 1970-01-01
      • 2019-01-04
      • 1970-01-01
      • 1970-01-01
      • 2012-12-15
      相关资源
      最近更新 更多