我有麻烦了。从HunterExpress API retieve价值观,我想为通过邮政编码,产品尺寸/重量等我使用下面的代码来获取运费我们怎样才能从API
取运费金额$data = array(
'username' => "xxx",
'password' => "xxx",
'customerCode' => "DUMMY",
'fromLocation' => array("suburbName"=> "MELBOURNE", "postCode"=> "3000", "state"=> "VIC"),
'toLocation' =>array("suburbName"=> "SYDNEY", "postCode"=> "2000", "state"=> "NSW"),
'goods' =>array("pieces"=> "2",
'weight' => "3",
'width' => "10",
'height' => "20",
'depth' => "12",
'typeCode' => "ENV")
);
$url = "https://api_link";//Api Link
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
echo $result;
但它并没有显示出任何结果,并没有错误
结果变量是空的还是什么? – 2014-09-03 03:39:30
结果变量为空 – user3931851 2014-09-03 03:41:10
它可能是API,它可能只是因为身份验证方法错误而丢失请求,请查看返回头文件。 – cujo 2014-09-03 03:41:14