You need to enable JavaScript to run this app.
导航

创意魔方

最近更新时间2023.05.12 14:27:04

首次发布时间2023.05.12 14:27:04

阅读本文,您可以快速了解创意魔方 PHP SDK 的使用方法。

说明

以下 SDK 示例中仅展示了部分参数,您可以在 veImageX 的接口文档中查看该接口支持的全部参数及取值。

前提条件

调用接口前请先完成初始化,具体操作请参考初始化

使用创意魔方获取结果图

您可使用创意魔方中预先创建好的样式 StyleId,定义需要设置的要素与要素的取值 Params,生成结果图,并获取结果图 URI。

具体参数详情和返回字段请参考 GetImageStyleResult。我们同时在 GitHub 上提供了参考示例

具体示例如下所示:

<?php
include_once(__DIR__ . '/../../vendor/autoload.php');

use Volc\Service\ImageX;

$client = ImageX::getInstance();

// call below method if you dont set ak and sk in ~/.volc/config
$client->setAccessKey("ak");
$client->setSecretKey("sk");

$query = [
    'ServiceId' => 'service id',
];

$body = [
    'StyleId' => 'style id',
    'Params' => [
        'key' => 'value',
    ],
    'OutputFormat' => 'jpeg',
    'OutputQuality' => 90,
];

$response = $client->getImageStyleResult($query, $body);
print_r($response);