Skip to content

Instantly share code, notes, and snippets.

@oh-sky oh-sky/hatebu.php
Created Jan 8, 2014

Embed
What would you like to do?
はてな認証APIを使って、はてなIDを取得するテスト
<?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
You can’t perform that action at this time.