【发布时间】:2014-05-22 10:22:00
【问题描述】:
我正在尝试使以下 OAuth 库正常工作:
https://github.com/sudocode/ohmy-auth
我正在尝试使用 Twitter API,但到目前为止我还没有成功。这看起来应该开箱即用。看起来请求无法正常工作。有谁知道这可能是什么问题?我还尝试了 OAuth 2.0 版本,但实际上什么也没做。
如果有人对如何使这项工作有任何建议,或者可以推荐一个更好的库,我将不胜感激任何帮助推进此工作的提示。
<?php require_once __DIR__ . '/../vendor/autoload.php';
use ohmy\Auth1;
$twitter = Auth1::legs(3)
# configuration
->set(array(
'key' => 'my-key',
'secret' => 'my-secret',
'callback' => 'my-callback-page'
))
# oauth flow
->request('https://api.twitter.com/oauth/request_token')
->authorize('https://api.twitter.com/oauth/authorize')
->access('https://api.twitter.com/oauth/access_token');
// test GET call
$twitter->GET('https://api.twitter.com/1.1/statuses/home_timeline.json', array('count' => 5))
->then(function($response) {
echo '<pre>';
var_dump($response->json());
echo '</pre>';
});
这是我被重定向到的 URL:https://api.twitter.com/oauth/authorize?oauth_token=
我收到消息:
Whoa there!
There is no request token for this page. That's the special key we need from applications asking to use your Twitter account. Please go back to the site or application that sent you here and try again; it was probably just a mistake.
【问题讨论】: