我试图让用户使用简单的Twitter登录来登录我的网站。我已经尝试按照https://twitteroauth.com/redirect.php上的说明进行操作,但提出了一个" Bad身份验证错误"直到我从键中删除了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有关 - 我很困惑。