Last active
December 14, 2015 14:29
-
-
Save taroyabuki/5100756 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
$oauth = new OAuth($_SESSION['consumer_key'], $_SESSION['consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI); | |
if (substr(PHP_OS, 0, 3) == 'WIN') { | |
$caPath = 'C:/xampp/perl/vendor/lib/Mozilla/CA/'; | |
$caInfo = "${caPath}cacert.pem"; | |
$oauth->setCAPath($caPath, $caInfo); | |
} | |
$oauth->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']); | |
$access_token = $oauth->getAccessToken('https://api.twitter.com/oauth/access_token?oauth_verifier' . $_GET['oauth_verifier']); | |
unset($_SESSION['oauth_token']); | |
unset($_SESSION['oauth_token_secret']); | |
//セッションに記録する。データベースなどを使ってもよい。 | |
$_SESSION['access_token'] = $access_token; | |
?> | |
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Twitter OAuth End</title> | |
</head> | |
<body> | |
<pre><?php print_r($access_token); ?></pre> | |
<p>access_tokenをセッションに保存した</p> | |
<p><a href="twitter-oauth-post.php">送信テスト</a></p> | |
<p><a href="logout.php">logout</a></p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment