我有麻煩了。從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