我正在集成shippo API到目前为止它工作得很好但是有这个问题,当我发送创建发货的请求正在创建但是在费率数组中没有任何东西但是当我通过邮递员发送相同的请求时我是在这里获得这些费率是我发送的请求。
// Receiver Information for making shipment.
$r_name = $result[0]->r_name;
$r_email = $result[0]->r_email;
$r_street = $result[0]->r_street;
$r_city = $result[0]->r_city;
$r_country = $result[0]->r_country;
$r_zip = $result[0]->r_zip;
$r_state = $result[0]->r_state;
// Sender Information for making Shipment.
$s_name = $result[0]->s_name;
$s_email = $result[0]->s_email;
$s_street = $result[0]->s_street;
$s_city = $result[0]->s_city;
$s_country = $result[0]->s_country;
$s_zip = $result[0]->s_zip;
$s_state = $result[0]->s_state;
// Parcel Information for making Shipment.
$p_qty = $result[0]->p_qty;
$p_name = $result[0]->p_name;
$p_price = $result[0]->p_price;
$p_weight = $result[0]->p_weight;
$p_unit = $result[0]->p_unit;
$shipment_array = array(
'address_to' => array(
'name' => $r_name,
'street1' => $r_street,
'city' => $r_city,
'state' => $r_state,
'zip' => $r_zip,
'country' => $r_country,
'phone' => '03212669686',
'email' => $r_email
),
'address_from' => array(
'name' => $s_name,
'street1' => $s_street,
'city' => $s_city,
'state' => $s_state,
'zip' => $s_zip,
'country' => $s_country,
'phone' => '03227577798',
'email' => $s_email
),
'parcels' => array(
array(
"length" => "10",
"width" => "15",
"height" => "10",
"distance_unit" => "in",
"weight" => $p_weight,
"mass_unit" => $p_unit
)
),
'async' => false
);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.goshippo.com/shipments/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($shipment_array),
CURLOPT_HTTPHEADER => array(
"Authorization: ShippoToken shippo_test_742eabd1c83ece80052fbce9ee71163181eaee72",
"Cache-Control: no-cache",
"Content-Type: application/json",
"Postman-Token: 906233f7-ac66-3951-f96a-4f0f88c8d419"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
任何人都可以帮我找出我在这里做错了什么。