Created
January 8, 2014 14:40
-
-
Save oh-sky/8317800 to your computer and use it in GitHub Desktop.
はてな認証APIを使って、はてなIDを取得するテスト
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 | |
$apiKey = ''; | |
$apiSecret = ''; | |
if (isset($_GET['cert'])) { | |
$apiSig = md5($apiSecret . 'api_key' . $apiKey . 'cert' . $_GET['cert']); | |
$jsonString = file_get_contents("http://auth.hatena.ne.jp/api/auth.json?api_key={$apiKey}&cert={$_GET['cert']}&api_sig={$apiSig}"); | |
$obj = json_decode($jsonString); | |
if (!$obj->has_error) { | |
echo file_get_contents("http://b.hatena.ne.jp/{$obj->user->name}/rss"); | |
exit(); | |
} | |
} | |
$apiSig = md5($apiSecret . 'api_key' . $apiKey); | |
$authUrl = "http://auth.hatena.ne.jp/auth?api_key={$apiKey}&api_sig={$apiSig}"; | |
header("Location: {$authUrl}"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment