我正在尝试为 hipchat 房间创建一个 curl 通知,它生成的通知令牌仅适用于该房间。
curl -d '{"color":"green","message":"My first notification
(yey)","notify":false,"message_format":"text"}' -H 'Content-Type:
application/json' <My URL and TOKEN GO HERE>
我的代码:
<?php
$payload = array("message"=>"testing");
print_r($payload);
$json = json_encode($payload,true);
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "my url with token"
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
$ch = curl_exec ($curl);
curl_close ($curl);
print_r($ch);
?>
结果我得到了这个:
Array
(
[message] => testing
)
{
"error": {
"code": 400,
"field": "message",
"message": "Required field 'message' is missing",
"type": "Bad Request",
"validation": "optional",
"value": null
}
我尝试了https://github.com/hipchat/hipchat-php和https://github.com/rcrowe/Hippy,但它们需要管理员 API 令牌。
谢谢, IJC