我正在尝试发送 REST 请求。系统文档给我的例子是这样的:
$ curl --digest -u admin:<passwd> http://1.2.3.4/r/users/12345/calls/recent
{"data": [
{"state_msg": "Finished",
"code": 200,
"dst_codecs": "PCMU,PCMA,iLBC,telephone-event",
"src_codecs": "PCMU,PCMA,telephone-event,iLBC",
"pid": 1250018007,
"url": "\/r\/users\/12345\/calls\/1250018007:16739",
[...]
}
[...]
]}
这个例子想告诉我什么?那里的数据信息是什么?那是我需要发送的吗?如果是这样,我将如何发送它?我读过这篇文章:Call a REST API in PHP但我仍然不确定如何构建我的调用。会是这样吗?
$data = array('state_msg' => 'state_msg','code'=>'200'.....);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "admin:<password>");
curl_setopt($curl, CURLOPT_URL, "http://1.2.3.4/r/users/12345/calls/recent");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);