Skip to content

提交图片生成任务

根据类型生成图片,结果将通过回调的方式告知,或通过主动查询接口获取生成结果。频率限制:500/s

请求参数类型描述
jsonobject声明请求的JSON数据结构
brand_idstring品牌ID
task_idstring图片生成的任务ID
image_generation_typestring图片生成类型
COMBINE_IMAGE | CUT_OUT 枚举值之一
combine_imageobject拼图数据
scopestring优惠范围
ALL | SINGLE 枚举值之一
typestring商品券类型
NORMAL | DISCOUNT | EXCHANGE 枚举值之一
usage_modestring使用模式
SINGLE | PROGRESSIVE_BUNDLE 枚举值之一
normal_couponobject满减券使用规则
thresholdinteger门槛金额
discount_amountinteger固定减免金额
discount_couponobject折扣券使用规则
thresholdinteger门槛金额
percent_offinteger固定减免百分比
exchange_couponobject兑换券使用规则
thresholdinteger门槛金额
exchange_priceinteger固定兑换价格
background_colorstring背景颜色色值
cut_outobject抠图数据
image_urlstring商品图URL
php
$instance->v3->marketing->partner->productCoupon->imageGenerationTasks->postAsync([
  'json' => [
    'brand_id'              => '120344',
    'task_id'               => 'image_generation_task_1',
    'image_generation_type' => 'COMBINE_IMAGE',
    'combine_image'         => [
      'scope'            => 'ALL',
      'type'             => 'NORMAL',
      'usage_mode'       => 'SINGLE',
      'normal_coupon'    => [
        'threshold'       => 10000,
        'discount_amount' => 1,
      ],
      'discount_coupon'  => [
        'threshold'   => 10000,
        'percent_off' => 20,
      ],
      'exchange_coupon'  => [
        'threshold'      => 10000,
        'exchange_price' => 20,
      ],
      'background_color' => '#ff5733',
    ],
    'cut_out'               => [
      'image_url' => 'https://wxpaylogo.qpic.cn/wxpaylogo/example.jpg',
    ],
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/marketing/partner/product-coupon/image-generation-tasks')->postAsync([
  'json' => [
    'brand_id'              => '120344',
    'task_id'               => 'image_generation_task_1',
    'image_generation_type' => 'COMBINE_IMAGE',
    'combine_image'         => [
      'scope'            => 'ALL',
      'type'             => 'NORMAL',
      'usage_mode'       => 'SINGLE',
      'normal_coupon'    => [
        'threshold'       => 10000,
        'discount_amount' => 1,
      ],
      'discount_coupon'  => [
        'threshold'   => 10000,
        'percent_off' => 20,
      ],
      'exchange_coupon'  => [
        'threshold'      => 10000,
        'exchange_price' => 20,
      ],
      'background_color' => '#ff5733',
    ],
    'cut_out'               => [
      'image_url' => 'https://wxpaylogo.qpic.cn/wxpaylogo/example.jpg',
    ],
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/marketing/partner/product-coupon/image-generation-tasks']->postAsync([
  'json' => [
    'brand_id'              => '120344',
    'task_id'               => 'image_generation_task_1',
    'image_generation_type' => 'COMBINE_IMAGE',
    'combine_image'         => [
      'scope'            => 'ALL',
      'type'             => 'NORMAL',
      'usage_mode'       => 'SINGLE',
      'normal_coupon'    => [
        'threshold'       => 10000,
        'discount_amount' => 1,
      ],
      'discount_coupon'  => [
        'threshold'   => 10000,
        'percent_off' => 20,
      ],
      'exchange_coupon'  => [
        'threshold'      => 10000,
        'exchange_price' => 20,
      ],
      'background_color' => '#ff5733',
    ],
    'cut_out'               => [
      'image_url' => 'https://wxpaylogo.qpic.cn/wxpaylogo/example.jpg',
    ],
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->marketing->partner->productCoupon->imageGenerationTasks->post([
  'json' => [
    'brand_id'              => '120344',
    'task_id'               => 'image_generation_task_1',
    'image_generation_type' => 'COMBINE_IMAGE',
    'combine_image'         => [
      'scope'            => 'ALL',
      'type'             => 'NORMAL',
      'usage_mode'       => 'SINGLE',
      'normal_coupon'    => [
        'threshold'       => 10000,
        'discount_amount' => 1,
      ],
      'discount_coupon'  => [
        'threshold'   => 10000,
        'percent_off' => 20,
      ],
      'exchange_coupon'  => [
        'threshold'      => 10000,
        'exchange_price' => 20,
      ],
      'background_color' => '#ff5733',
    ],
    'cut_out'               => [
      'image_url' => 'https://wxpaylogo.qpic.cn/wxpaylogo/example.jpg',
    ],
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/marketing/partner/product-coupon/image-generation-tasks')->post([
  'json' => [
    'brand_id'              => '120344',
    'task_id'               => 'image_generation_task_1',
    'image_generation_type' => 'COMBINE_IMAGE',
    'combine_image'         => [
      'scope'            => 'ALL',
      'type'             => 'NORMAL',
      'usage_mode'       => 'SINGLE',
      'normal_coupon'    => [
        'threshold'       => 10000,
        'discount_amount' => 1,
      ],
      'discount_coupon'  => [
        'threshold'   => 10000,
        'percent_off' => 20,
      ],
      'exchange_coupon'  => [
        'threshold'      => 10000,
        'exchange_price' => 20,
      ],
      'background_color' => '#ff5733',
    ],
    'cut_out'               => [
      'image_url' => 'https://wxpaylogo.qpic.cn/wxpaylogo/example.jpg',
    ],
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/marketing/partner/product-coupon/image-generation-tasks']->post([
  'json' => [
    'brand_id'              => '120344',
    'task_id'               => 'image_generation_task_1',
    'image_generation_type' => 'COMBINE_IMAGE',
    'combine_image'         => [
      'scope'            => 'ALL',
      'type'             => 'NORMAL',
      'usage_mode'       => 'SINGLE',
      'normal_coupon'    => [
        'threshold'       => 10000,
        'discount_amount' => 1,
      ],
      'discount_coupon'  => [
        'threshold'   => 10000,
        'percent_off' => 20,
      ],
      'exchange_coupon'  => [
        'threshold'      => 10000,
        'exchange_price' => 20,
      ],
      'background_color' => '#ff5733',
    ],
    'cut_out'               => [
      'image_url' => 'https://wxpaylogo.qpic.cn/wxpaylogo/example.jpg',
    ],
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
task_idstring图片生成的任务ID
brand_idstring品牌ID

参阅 官方文档 官方文档

Published on the GitHub by TheNorthMemory