Skip to content

Instantly share code, notes, and snippets.

@mgng
Last active October 23, 2015 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgng/d9c42698db43c1611280 to your computer and use it in GitHub Desktop.
Save mgng/d9c42698db43c1611280 to your computer and use it in GitHub Desktop.
im.kayac.com post test
<?php
// im.kayac.com 送信テスト
$api_url = "http://im.kayac.com/api/post/あなたのユーザ名";
$password = "設定したパスワード";
// $secret_key = "設定した秘密鍵";
$message = "日本語メッセージテスト!\n改行あるとどうなる?";
$content = http_build_query(array(
"message" => $message,
"password" => $password,
// "sig" => sha1("{$message}{$secret_key}"), // 秘密鍵認証する場合はこっち
));
$header = array(
"Content-Type: application/x-www-form-urlencoded",
"Content-Length: " . strlen($content),
);
$response = file_get_contents($api_url, false, stream_context_create(array(
"http" => array(
"method" => "POST",
"header" => implode("\r\n", $header),
"content" => $content,
),
)));
var_dump($response);
// string(40) "{"error":"","id":null,"result":"posted"}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment