im.kayac.comは最高に便利。
$username = 'testuser';
$password = 'testpass';
$data = array(
"message" => "ほげほえ",
"password" => $password,
);
$data['sig'] = sha1($data['message'] . $data['password']);
unset($data['password']);
$data = http_build_query($data, "", "&");
//header
$header = array(
"Content-Type: application/x-www-form-urlencoded",
"Content-Length: ".strlen($data)
);
$context = array(
"http" => array(
"method" => "POST",
"header" => implode("rn", $header),
"content" => $data
)
);
$url = "http://im.kayac.com/api/post/{$username}";
echo file_get_contents($url, false, stream_context_create($context));
なくしそうだったのでここにメモしておく。
Related posts: