[英]Getting “Could not authenticate you” at connection stage with Abraham's TwitterOAuth
I'm trying to let users log in to my site using a simple twitter log in. I've tried following the instructions on https://twitteroauth.com/redirect.php but that came up with an "Bad Authentication Error" until I removed the getenv() from the keys. 我试图让用户使用一个简单的twitter登录名登录我的网站。我尝试按照https://twitteroauth.com/redirect.php上的说明进行操作,但是出现了“身份验证错误”的问题,直到我从键中删除了getenv()。
Here's my code: 这是我的代码:
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));
And the response: 以及响应:
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
Every search I've done on SO and Google seems to related to an older version of twitteroauth - I'm very confused. 我在SO和Google上进行的每一次搜索似乎都与旧版本的twitteroauth有关-我非常困惑。
If anyone else is coming up against this - the solution I found was to ditch TwitterOAuth and I used HybridAuth instead. 如果还有其他人遇到这个问题,我发现的解决方案是抛弃TwitterOAuth,改用HybridAuth 。 Far easier.
容易得多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.