图片上传
商品券接口调用过程中需要传入各种图片URL,请使用本接口上传图片到微信支付,并使用接口返回的URL。
请求参数 | 类型 | 描述 |
---|---|---|
body | object | multipart/form-data 数据结构 |
file | object | 媒体图⽚只⽀持JPG、BMP、PNG格式,⽂件⼤⼩不能超过2M。 |
meta | string | 媒体文件元信息,使用JSON 表示,包含两个参数:sha256 、filename |
sha256 | string | 图片文件的sha256 摘要 |
filename | string | 商户上传的媒体图片的名称,商户自定义,必须以JPG、BMP、PNG为后缀 |
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/image.jpg');
$instance->v3->marketing->partner->productCoupon->media->uploadImage->postAsync([
'body' => $media->getStream(),
'headers' => [
'Content-Type' => $media->getContentType(),
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/image.jpg');
$instance->chain('v3/marketing/partner/product-coupon/media/upload-image')->postAsync([
'body' => $media->getStream(),
'headers' => [
'Content-Type' => $media->getContentType(),
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/image.jpg');
$instance['v3/marketing/partner/product-coupon/media/upload-image']->postAsync([
'body' => $media->getStream(),
'headers' => [
'Content-Type' => $media->getContentType(),
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/image.jpg');
$response = $instance->v3->marketing->partner->productCoupon->media->uploadImage->post([
'body' => $media->getStream(),
'headers' => [
'Content-Type' => $media->getContentType(),
],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/image.jpg');
$response = $instance->chain('v3/marketing/partner/product-coupon/media/upload-image')->post([
'body' => $media->getStream(),
'headers' => [
'Content-Type' => $media->getContentType(),
],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/image.jpg');
$response = $instance['v3/marketing/partner/product-coupon/media/upload-image']->post([
'body' => $media->getStream(),
'headers' => [
'Content-Type' => $media->getContentType(),
],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典 | 类型 | 描述 |
---|---|---|
media_url | string | 媒体文件URL地址 |
参阅 官方文档