Skip to content

Instantly share code, notes, and snippets.

@mgng
Last active Oct 23, 2015
Embed
What would you like to do?
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