我需要在PHP curl中复制相同的POST请求。请求参数应该在正文中的json中,响应也是json对象。
{
"api_key": "scTrCT",
"test": "true",
"service_provider_list": [
{
"facility_name": "ALL YOUR SMILE NEEDS DENTAL CENTERS",
"provider_name": "DRS. HERMAN AND MACK P.C",
"tax_id": "12345678
}
],
"payer_ids": [
"00431"
],
"transaction_type": "270",
"effective_date": "2014-01-12"
}
答案 0 :(得分:0)
请试试这个:
<?php
$json = array(
"api_key" => "scTrCT",
"test" => "true",
"service_provider_list" => array(
"facility_name" => "ALL YOUR SMILE NEEDS DENTAL CENTERS",
"provider_name" => "DRS. HERMAN AND MACK P.C",
"tax_id" => "12345678"
),
"payer_ids" => array(
"00431"
),
"transaction_type" => "270",
"effective_date" => "2014-01-12"
);
$json = json_encode($json);
$ch = curl_init('http://gds.eligibleapi.com/v1.3/enrollment.json');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
echo $result;