【发布时间】:2020-09-07 00:03:26
【问题描述】:
我的情况是
- 使用 Laravel 7
- 想使用 Shopee API
在 Laravel 中发送请求应该是这样的
$res = Http::withHeaders([
'Content-Type' => 'application/json',
'Authorization' => $secret_key
])->post($api_url, [
"ordersn_list" => [$order_no],
"shopid" => $shop_id,
"partner_id" => $partner_id,
"timestamp" => $timestamp
]);
但是 Shopee API 在正文部分不需要空格(不能以 JSON 格式发送)。我试过了
$res = Http::withHeaders([
'Content-Type' => 'application/json',
'Authorization' => $secret_key
])->post($api_url, $body_string);
它不起作用,因为它必须是一个数组。返回错误Argument 2 passed to Illuminate\Http\Client\PendingRequest::post() must be of the type array, string given
.
【问题讨论】:
-
你能解释一下
But Shopee API needs no space in the body part