【发布时间】: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();
【问题讨论】: