【发布时间】:2017-10-18 15:47:14
【问题描述】:
我正在使用 Guzzle for Laravel 为 Webservice 发送 POST,但我无法访问数组来发送图片。这就是我需要遵循的结构:
{
"title": "xxxxxxxxxxxxxxxxx",
"category_id": "XXXX",
"official_store_id": null,
"pictures": [
{
"id": "XXXXX",
"url": "http://mlb-s1-p.mlstatic.com/292325-MLB25432321923_032017-O.jpg",
"secure_url": "https://mlb-s1-p.mlstatic.com/292325-MLB25432321923_032017-O.jpg",
"size": "500x500",
"max_size": "500x500",
"quality": ""
}
],
}
我尝试这样发送:
$r = $client->request('POST', 'https://api.mercadolibre.com/items?access_token='.$token->erp_access_token, [
'json' => [
'title' => $name,
'category_id' => $cat2,
'price' => $price,
'currency_id' => 'BRL',
'available_quantity' => $quantity,
'buying_mode' => 'buy_it_now',
'listing_type_id' => 'gold_special',
'condition' => 'new',
'description' => $description,
'pictures' => [
'url' => $image
]
]
]);
返回错误:
{"message":"body.invalid_field_types","error":"[invalid property type: [pictures] expected List but was JSONObject value (truncated...)
我阅读了 Guzzle 文档,但没有找到该案例的任何示例。
有什么建议吗?
【问题讨论】: