获取“无法验证您的身份”;在与亚伯拉罕的TwitterOAuth连接阶段


Getting "Could not authenticate you" at connection stage with Abraham's TwitterOAuth

我试图让用户登录到我的网站使用一个简单的twitter登录。我试着按照https://twitteroauth.com/redirect.php上的说明,但出现了一个"糟糕的身份验证错误",直到我从密钥中删除了getenv()。

下面是我的代码:

require "twitteroauth/autoload.php";
use Abraham'TwitterOAuth'TwitterOAuth;
define('CONSUMER_KEY', '<<MY KEY>>');
define('CONSUMER_SECRET', '<<MY SECRET>>');
define('OAUTH_CALLBACK', 'http://www.example.com/inside/index.php');
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
$request_token = $connection->oauth('oauth/request_token', array('oauth_callback' => OAUTH_CALLBACK));

和响应:

Fatal error: Uncaught exception 'Abraham'TwitterOAuth'TwitterOAuthException' with message '{"errors":[{"code":32,"message":"Could not authenticate you."}]}' in /home/sites/site2/web/inside/twitteroauth/src/TwitterOAuth.php:141 Stack trace: #0 /home/sites/site2/web/inside/index.php(12): Abraham'TwitterOAuth'TwitterOAuth->oauth('oauth/request_t...', Array) #1 {main} thrown in /home/sites/site2/web/inside/twitteroauth/src/TwitterOAuth.php on line 141

我在SO和Google上做的每一个搜索似乎都与旧版本的twitteroauth有关-我很困惑

如果有人遇到这个问题-我发现的解决方案是放弃TwitterOAuth,而使用HybridAuth。要容易得多。