im.kayac.comにPHPで秘密鍵認証使って送信する

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:

  1. Ethnaで手軽にCSRF対策する
  2. livedoorクリップのAPIを使ってみる
  3. value-domainのDDNS更新スクリプト
  4. nanowebが久しぶりにバージョンアップしている!!
  5. preg_matchでのキャプチャをシンプルに

コメントをどうぞ

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

*

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

ねこ認証:9つのパネルの中からねこを3匹選んでください

Additional comments powered byBackType