以下json_decode
返回null。
$messages = file_get_contents(json_decode($json_message_goes_here));
$json_message
如下所示
{"messages":[{"type":"incident.resolve","data":{"incident":{"id":"P4M9D68","incident_number":10723,"created_on":"2015-08-03T14:01:09Z","status":"resolved","pending_actions":[],"html_url":"http://test.com","incident_key":"27fb39e942ea49bcbc63849a4e53b738","service":{"id":"P19F6J5","name":"Wormly","html_url":"some_url","deleted_at":null},"escalation_policy":{"id":"P58IXAM","name":"Default","deleted_at":null},"assigned_to_user":null,"trigger_summary_data":{"subject":"PD2JIRA"},"trigger_details_html_url":"some_url","trigger_type":"web_trigger","last_status_change_on":"2015-08-03T14:01:32Z","last_status_change_by":{"id":"P7ZDR6H","name":"some name","email":"some_email","html_url":"some_url"},"number_of_escalations":0,"resolved_by_user":{"id":"P7ZDR6H","name":"some name","email":"some email","html_url":"some url"},"assigned_to":[],"urgency":"high"}},"id":"260a18e0-39e8-11e5-8dcf-22000ad9bf74","created_on":"2015-08-03T14:01:32Z"}]}
尝试在以下网址验证,并显示它是有效的JSON输入数据 http://jsonlint.com/
在PHP 5.6 wamp服务器上运行它
答案 0 :(得分:4)
json消息看起来正确,但为什么使用file_get_contents?您没有加载文件。试试这个:
$messages = json_decode($json_message);