[英]How to pass nested array in curl
我想在 curl 中传递嵌套数组。 当我尝试这是我得到的错误消息
“(!)解析错误:语法错误,第 39 行中出现意外的 '=>' (T_DOUBLE_ARROW)”
这意味着“=>”这个语法是错误的
我尝试不使用括号它也不起作用。 我怎样才能传递这个数组?
$baseurl = 'http://202.124.173.187/api/v1/payConfirm';
$rawPOSTdata = array
(
"deviceCode"=>"",
"applicationId"=>"",
"patient",(
"member"=>"",
"needSMS"=>"true",
"nsr"=>"",
"foreign"=>"",
"teleNo"=>"0777136419",
"title"=>"mrs",
"patientName"=>"sufra",
"nid"=>"887111596v",
)
"sessionDetails",
(
"hosId"=>"H138",
"docId"=>"D3648",
"theDay"=>"Monday",
"startTime"=>"13:00",
"theDate"=>"03-10-2016",
)
"payment",
(
"paymentMode"=>"EPG",
"bankCode"=>"",
"branchCaode"=>"M000444",
"paymentChannel"=>"WEB_PO",
"channelFrom"=>"W",
)
);
$curl = curl_init($baseurl);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-type: multipart/form-data',"Authorization: Bearer $atoken"));
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($rawPOSTdata));
$response = curl_exec($curl);
curl_close($curl);
if( $response )
{
if ( isset($result->error) )die( $result->error_message );
/* Convert json data to array */
$arr=json_decode( $response,true);
echo '<pre>';echo print_r ($arr); echo '</pre>';
使用这个数组,嵌套数组应该再次写成 array() 如下
$rawPOSTdata = array(
"deviceCode"=>"",
"applicationId"=>"",
"patient" => array(
"member"=>"",
"needSMS"=>"true",
"nsr"=>"",
"foreign"=>"",
"teleNo"=>"0777136419",
"title"=>"mrs",
"patientName"=>"sufra",
"nid"=>"887111596v",
),
"sessionDetails" => array(
"hosId"=>"H138",
"docId"=>"D3648",
"theDay"=>"Monday",
"startTime"=>"13:00",
"theDate"=>"03-10-2016",
),
"payment" => array(
"paymentMode"=>"EPG",
"bankCode"=>"",
"branchCaode"=>"M000444",
"paymentChannel"=>"WEB_PO",
"channelFrom"=>"W",
),
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.