【问题标题】:Fatal error: Call to undefined method TwitterOAuth::getRequestToken()致命错误:调用未定义的方法 TwitterOAuth::getRequestToken()
【发布时间】:2015-11-11 00:34:13
【问题描述】:

我正在与 Abraham 的 twitteroauth 合作在我的应用程序中实现 Twitter OAuth。在运行我的应用程序时,这是我遇到的错误:

Fatal error: Call to undefined method TwitterOAuth::getRequestToken() in /opt/lampp/htdocs/tmhOAuth-master/login_twitter.php on line 12

login_twitter.php

<?php
session_start();
ini_set('display_errors', '1');

require_once('config.php');
// new file, I have saved my app's key and secret in config.php

require("twitteroauth.php");

$twitteroauth = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
// Requesting authentication tokens, the parameter is the URL we will be redirected to callback url
$request_token = $twitteroauth->getRequestToken('http://localhost/tmhOAuth-master/get_twitter_tokens.php');

// Saving them into the session

$_SESSION['oauth_token'] = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];


// If everything goes well..
if ($twitteroauth->http_code == 200) {
    // Let's generate the URL and redirect
    $url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']);

    header('Location: ' . $url);
} else {
    // It's a bad idea to kill the script, but we've got to know when there's an error.
    die('Something wrong happened.');
}

?>

getRequestToken() 方法似乎有什么问题?

【问题讨论】:

    标签: php twitter oauth oauth-2.0 twitter-oauth


    【解决方案1】:

    该方法已替换为 oauth 方法。请通读当前方法名称的登录流程。 https://twitteroauth.com

    在这里查看问题https://github.com/abraham/twitteroauth/issues/321。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-28
      • 2015-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-03
      • 2012-01-06
      相关资源
      最近更新 更多