【发布时间】:2018-01-09 18:48:02
【问题描述】:
我正在尝试向 API 发送帖子,但返回“items should be an array”错误。
$response2 = $client2->request('POST', 'https://api.iugu.com/v1/invoices?api_token='.$token, [
'form_params' => [
'email' => $email,
'due_date' => $due_date,
'items' => ['description' =>
'Item Um',
'quantity' => 1,
'price_cents' => 1000
],
'payer' => [
'cpf_cnpj' => $cpf_cnpj,
'name' => $name,
'phone_prefix' => $phone_prefix,
'phone' => $phone,
'email' => $email,
'address' => [
'zip_code' => $zip_code,
'street' => $street,
'number' => $number,
'district' => $district,
'city' => $city,
'state' => $state,
'country' => 'Brasil',
'complement' => $complement
]
]
]
]);
我已经尝试了多种方式。
['items' => 'description' =>
'Item Um',
'quantity' => 1,
'price_cents' => 1000
],
但是没有一种方法能显示出我想要的结果。这很奇怪,因为当我使用 PHP 和 CURL lib 运行时,这段代码就像魅力一样。
有什么建议吗?提前感谢社区!
【问题讨论】:
标签: php arrays laravel curl guzzle