如何解析 JSON 和访问结果返回值
我正在使用 CURL 发送请求。响应数据类型为 。如何解析此数据并将其插入数据库?json
<?php
$url = 'http://sms2.cdyne.com/sms.svc/SimpleSMSsendWithPostback? PhoneNumber=18887477474&Message=test&LicenseKey=LICENSEKEY';
$cURL = curl_init();
curl_setopt($cURL, CURLOPT_URL, $url);
curl_setopt($cURL, CURLOPT_HTTPGET, true);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json'
));
$result = curl_exec($cURL);
curl_close($cURL);
print_r($result);
?>
JSON 输出:
{
"Cancelled": false,
"MessageID": "402f481b-c420-481f-b129-7b2d8ce7cf0a",
"Queued": false,
"SMSError": 2,
"SMSIncomingMessages": null,
"Sent": false,
"SentDateTime": "/Date(-62135578800000-0500)/"
}