<?php
$AppKey = '';
$HMKey = '';
$CT = '';
function authenticate_2chapi($AppKey, $CT, $HMKey)
{
$url = 'https://api.2ch.net/v1/auth/';
$message = $AppKey.$CT;
$HB = hash_hmac("sha256", $message, $HMKey);
$values = array(
'ID' => '',
'PW' => '',
'KY' => $AppKey,
'CT' => $CT,
'HB' => $HB,
);
$options = array('http' => array(
'method' => 'POST',
'header' => implode("\r\n", array(
'User-Agent: ',
'X-2ch-UA: JaneStyle/3.80',
'Content-Type: application/x-www-form-urlencoded',
)),
'content' => http_build_query($values),
));
$response = file_get_contents($url, false, stream_context_create($options));
$sid = explode(':', $response);
return $sid[1];
}
function getDAT_2chapi($serverName, $boardName, $threadId, $sid, $AppKey, $HMKey)
{
$url = 'https://api.2ch.net/v1/'.$serverName.'/'.$boardName.'/'.$threadId;
$message = '/v1/'.$serverName.'/'.$boardName.'/'.$threadId.$sid.$AppKey;
$HB = hash_hmac("sha256", $message, $HMKey);
$values = array(
'sid' => $sid,
'hobo' => $HB,
'appkey' => $AppKey,
);
$options = array('http' => array(
'method' => 'POST',
'header' => implode("\r\n", array(
'User-Agent: Mozilla/3.0 (compatible; JaneStyle/3.80..)',
'Connection: close',
'Content-Type: application/x-www-form-urlencoded',
'Accept-Encoding: gzip',
)),
'content' => http_build_query($values),
));
$response = file_get_contents($url, false, stream_context_create($options));
return gzdecode($response);
}
$sid = authenticate_2chapi($AppKey, $CT, $HMKey);
$dat = getDAT_2chapi('anago', 'software', '1424405198', $sid, $AppKey, $HMKey);
echo $dat;
?>