Skip to content

Instantly share code, notes, and snippets.

@ku-suke
Created February 6, 2014 14:04
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 ku-suke/8844773 to your computer and use it in GitHub Desktop.
Save ku-suke/8844773 to your computer and use it in GitHub Desktop.
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