Created
December 11, 2013 07:22
-
-
Save t-kashima/7906269 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// チャットワークのAPIの設定 | |
$baseurl = 'https://api.chatwork.com/v1/rooms'; | |
$room_id = 'ROOM_ID'; | |
$apikey = 'API_KEY'; | |
// 書き込むメッセージ | |
$message_file = 'message.txt'; | |
// 書き込むメッセージを取得する | |
$message = file_get_contents($message_file); | |
// クエリを作成する | |
$query = http_build_query(array('body' => $message)); | |
// ヘッダーを作成する | |
$headers = array( | |
'Content-Type: application/x-www-form-urlencoded', | |
'Content-Length: ' . strlen($query), | |
'X-ChatWorkToken: ' . $apikey | |
); | |
// 通信(POSTリクエスト)のための設定をする | |
$opts = array('http' => | |
array( | |
'method' => 'POST', | |
'header' => implode("\r\n", $headers), | |
'content' => $query | |
) | |
); | |
$context = stream_context_create($opts); | |
// 通信 | |
$url = $baseurl . '/' . $room_id . '/messages'; | |
$content = file_get_contents($url, false, $context); | |
// echo $content . "\n"; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
, -=ニ=-ー=ニ~~ヽ__ | |
_/::::::::::::::::::::::::::::::::::::::::::::::~`ヽ、 わたしが山下です。 | |
/::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::ヽ | |
/:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::i | |
i:::::::::::::::::::::::::::_,. -"~`ー-----------一- 、_:::::::'、 | |
ゞ::::::::::::::::::::::/ ~ヽ:::.ヽ | |
/::::::::::::::::__, / ヽ:.:/ | |
(:::::::::::/~~ --,,_ Y | |
〉:::::::::ヽ /----- ”"=;,_ l -='¨~` | | |
/入ヽ::::./-----------------| `ー-- |--/ ' .|,ー-` | / | |
// ))/ \_______ / / \ーー/ l | |
ヽ `-i ( ヽ.. i | |
ヽ` 、 / ~ ~. ヽ i | |
i / // ,,,; i | |
. _i i i ,`===ニ二ニ===ニ二彡" l | |
("~i ! ` ~¨¨~ ̄`゚゙'`^~ l i | |
/い.i .i l. / | |
いi ヽ、 ノ / | |
.i ヽ、` / | |
~` - 、_ 、 ノ | |
~ニ=-~ニ=ー- . ,, -=ニ~ | |
~` ~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment