Skip to content

图片下载

下载图片API为通用接口,消费者投诉相关图片都可以通过该接口进行下载。

请求参数类型描述
media_idstring媒体文件ID
php
$mediaUrl = 'https://api.mch.weixin.qq.com/v3/merchant-service/images/xxxxx';
$uri = new \GuzzleHttp\Psr7\Uri($mediaUrl);
$segment = \substr($uri->getPath(), 28);

$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./image.jpg', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$instance->v3->merchantService->images->_media_id_->getAsync([
  'sink' => $stream,
  'media_id' => \rawurldecode($segment),
])
->wait();
php
$mediaUrl = 'https://api.mch.weixin.qq.com/v3/merchant-service/images/xxxxx';
$uri = new \GuzzleHttp\Psr7\Uri($mediaUrl);
$segment = \substr($uri->getPath(), 28);

$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./image.jpg', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$instance->chain('v3/merchant-service/images/{media_id}')->getAsync([
  'sink' => $stream,
  'media_id' => \rawurldecode($segment),
])
->wait();
php
$mediaUrl = 'https://api.mch.weixin.qq.com/v3/merchant-service/images/xxxxx';
$uri = new \GuzzleHttp\Psr7\Uri($mediaUrl);
$segment = \substr($uri->getPath(), 28);

$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./image.jpg', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$instance['v3/merchant-service/images/{media_id}']->getAsync([
  'sink' => $stream,
  'media_id' => \rawurldecode($segment),
])
->wait();
php
$mediaUrl = 'https://api.mch.weixin.qq.com/v3/merchant-service/images/xxxxx';
$uri = new \GuzzleHttp\Psr7\Uri($mediaUrl);
$segment = \substr($uri->getPath(), 28);

$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./image.jpg', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$instance->v3->merchantService->images->_media_id_->get([
  'sink' => $stream,
  'media_id' => \rawurldecode($segment),
]);
php
$mediaUrl = 'https://api.mch.weixin.qq.com/v3/merchant-service/images/xxxxx';
$uri = new \GuzzleHttp\Psr7\Uri($mediaUrl);
$segment = \substr($uri->getPath(), 28);

$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./image.jpg', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$instance->chain('v3/merchant-service/images/{media_id}')->get([
  'sink' => $stream,
  'media_id' => \rawurldecode($segment),
]);
php
$mediaUrl = 'https://api.mch.weixin.qq.com/v3/merchant-service/images/xxxxx';
$uri = new \GuzzleHttp\Psr7\Uri($mediaUrl);
$segment = \substr($uri->getPath(), 28);

$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./image.jpg', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$instance['v3/merchant-service/images/{media_id}']->get([
  'sink' => $stream,
  'media_id' => \rawurldecode($segment),
]);
返回字典类型描述
文件流(保存后按本地图片查看)

参阅 官方文档 官方文档

Published on the GitHub by TheNorthMemory