Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
New Relicのalert WebhookをPHPで受け取る。(deployは無視。jsonそのまま流す。)
<?php
// see also: http://qiita.com/wings1685/items/9090f59ab09e73f7c8fb
if(!isset($_POST["alert"])){
return;
}
$body = $_POST["alert"];
// おこのみでjsonをdumpする。
$option = array('body' => $body);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.chatwork.com/v1/rooms/{room_id}/messages');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-ChatWorkToken: YOUR API KEY'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($option, '', '&'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
//header('Content-type: application/json; charset=utf-8');
//echo $response;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment