以下是我用来获取oauth和oauth密钥的内容。如何获取用户访问令牌和访问令牌密钥?我没有在文档中看到任何使用上述令牌获取它们的过程。
感谢您提前的支持!
require("twitteroauth/twitteroauth.php");
// The TwitterOAuth instance
$twitteroauth = new TwitterOAuth('YOUR_CONSUMER_KEY', 'YOUR_CONSUMER_SECRET');
// Requesting authentication tokens, the parameter is the URL we will be redirected to
$request_token = $twitteroauth->getRequestToken('localhost.com/…');
// 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.');
}
感谢您提前的支持!