2015-08-18 87 views
0

我正在與亞伯拉罕的twitteroauth在我的應用程序中實現Twitter OAuth。當運行我的應用程序,這是我遇到的錯誤:什麼似乎是錯的getRequestToken()方法致命錯誤:調用未定義的方法TwitterOAuth :: getRequestToken()

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.'); 
} 

?> 

回答

相關問題