You need to enable JavaScript to run this app.
文档中心
图像生成大模型

图像生成大模型

复制全文
下载 pdf
交付中心
炉米HTTP请求示例
复制全文
下载 pdf
炉米HTTP请求示例
前置说明(必读)​
以下内容为直接使用HTTP方式调用接口的请求示例(包含签名过程),替换关键信息即可直接调用。​
Step1(必需): 通过火山访问控制获取AK/SK,需确保火山账号已开通对应权限和相关策略​
  • 正确替换示例中的AccessKeyID和SecretAccessKey参数值​
  • 无权限情况下会报错​
Step2(大多数情况下可跳过): 查看接口文档请求参数-Query参数中的Action及对应Version​
  • 正确替换示例中的action和 version参数值​
Step3(必需): 查看接口文档请求参数-Body参数​
  • 正确替换示例中的Body入参​
Step4: 运行程序进行调试即可,待测试调通后,可以按需集成到项目中(不建议直接Copy,建议自行适配或更新包)​
调用示例​
Java​
​
package org.example.LuMi;​
import com.alibaba.fastjson.JSONArray;​
import com.alibaba.fastjson.JSONObject;​
​
import javax.crypto.Mac;​
import javax.crypto.spec.SecretKeySpec;​
​
​
import java.io.InputStream;​
import java.io.OutputStream;​
import java.net.HttpURLConnection;​
import java.net.URL;​
import java.nio.ByteBuffer;​
import java.nio.charset.Charset;​
import java.nio.charset.StandardCharsets;​
import java.security.MessageDigest;​
import java.text.SimpleDateFormat;​
import java.util.*;​
​
public class LuMiTyT2vTest {​
​
private static final BitSet URLENCODER = new BitSet(256);​
​
private static final String CONST_ENCODE = "0123456789ABCDEF";​
public static final Charset UTF_8 = StandardCharsets.UTF_8;​
​
private final String region;​
private final String service;​
private final String schema;​
private final String host;​
private final String path;​
private final String ak;​
private final String sk;​
​
static {​
int i;​
for (i = 97; i <= 122; ++i) {​
URLENCODER.set(i);​
}​
​
for (i = 65; i <= 90; ++i) {​
URLENCODER.set(i);​
}​
​
for (i = 48; i <= 57; ++i) {​
URLENCODER.set(i);​
}​
URLENCODER.set('-');​
URLENCODER.set('_');​
URLENCODER.set('.');​
URLENCODER.set('~');​
}​
​
public LuMiTyT2vTest(String region, String service, String schema, String host, String path, String ak, String sk) {​
this.region = region;​
this.service = service;​
this.host = host;​
this.schema = schema;​
this.path = path;​
this.ak = ak;​
this.sk = sk;​
}​
​
public static void main(String[] args) throws Exception {​
String AccessKeyID = "";​
String SecretAccessKey = "";​
// 请求地址​
String endpoint = "visual.volcengineapi.com";​
String path = "/"; // 路径,不包含 Query// 请求接口信息​
String service = "cv";​
String region = "cn-north-1";​
String schema = "https";​
LuMiTyT2vTest sign = new LuMiTyT2vTest(region, service, schema, endpoint, path, AccessKeyID, SecretAccessKey);​
​
String action = "LumiSync2AsyncSubmitTask";​
String version = "2025-06-01";​
​
Date date = new Date();​
HashMap<String, String> queryMap = new HashMap<>() {{​
// put("Limit", "1");​
}};​
​
JSONObject jsonObject = new JSONObject();​
​
jsonObject.put("req_key", "lumi_ty_t2v_test"); ​
jsonObject.put("res_quota_name", "Untitle"); ​
​
// 构建req_json嵌套对象,添加text字段​
JSONObject reqJson = new JSONObject();​
reqJson.put("text", "生成一个小孩在田野里放风筝");​
// 将req_json对象加入主请求JSON​
jsonObject.put("req_json", reqJson);​
​
sign.doRequest("POST", queryMap, JSONObject.toJSONBytes(jsonObject), date, action, version);​
}​
​
public void doRequest(String method, Map<String, String> queryList, byte[] body,​
Date date, String action, String version) throws Exception {​
if (body == null) {​
body = new byte[0];​
}​
String xContentSha256 = hashSHA256(body);​
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");​
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));​
String xDate = sdf.format(date);​
String shortXDate = xDate.substring(0, 8);​
String contentType = "application/json";​
​
String signHeader = "host;x-date;x-content-sha256;content-type";​
​
​
SortedMap<String, String> realQueryList = new TreeMap<>(queryList);​
realQueryList.put("Action", action);​
realQueryList.put("Version", version);​
StringBuilder querySB = new StringBuilder();​
for (String key : realQueryList.keySet()) {​
querySB.append(signStringEncoder(key)).append("=").append(signStringEncoder(realQueryList.get(key))).append("&");​
}​
querySB.deleteCharAt(querySB.length() - 1);​
​
String canonicalStringBuilder = method + "\n" + path + "\n" + querySB + "\n" +​
"host:" + host + "\n" +​
"x-date:" + xDate + "\n" +​
"x-content-sha256:" + xContentSha256 + "\n" +​
"content-type:" + contentType + "\n" +​
"\n" +​
signHeader + "\n" +​
xContentSha256;​
​
System.out.println(canonicalStringBuilder);​
​
String hashcanonicalString = hashSHA256(canonicalStringBuilder.getBytes());​
String credentialScope = shortXDate + "/" + region + "/" + service + "/request";​
String signString = "HMAC-SHA256" + "\n" + xDate + "\n" + credentialScope + "\n" + hashcanonicalString;​
​
byte[] signKey = genSigningSecretKeyV4(sk, shortXDate, region, service);​
String signature = HexFormat.of().formatHex(hmacSHA256(signKey, signString));​
​
​
URL url = new URL(schema + "://" + host + path + "?" + querySB);​
​
​
HttpURLConnection conn = (HttpURLConnection) url.openConnection();​
conn.setRequestMethod(method);​
conn.setRequestProperty("Host", host);​
conn.setRequestProperty("X-Date", xDate);​
conn.setRequestProperty("X-Content-Sha256", xContentSha256);​
conn.setRequestProperty("Content-Type", contentType);​
conn.setRequestProperty("Authorization", "HMAC-SHA256" +​
" Credential=" + ak + "/" + credentialScope +​
", SignedHeaders=" + signHeader +​
", Signature=" + signature);​
if (!Objects.equals(conn.getRequestMethod(), "GET")) {​
conn.setDoOutput(true);​
OutputStream os = conn.getOutputStream();​
os.write(body);​
os.flush();​
os.close();​
}​
conn.connect();​
​
int responseCode = conn.getResponseCode();​
​
InputStream is;​
if (responseCode == 200) {​
is = conn.getInputStream();​
} else {​
is = conn.getErrorStream();​
}​
String responseBody = new String(is.readAllBytes());​
is.close();​
​
System.out.println(responseCode);​
System.out.println(responseBody);​
}​
​
private String signStringEncoder(String source) {​
if (source == null) {​
return null;​
}​
StringBuilder buf = new StringBuilder(source.length());​
ByteBuffer bb = UTF_8.encode(source);​
while (bb.hasRemaining()) {​
int b = bb.get() & 255;​
if (URLENCODER.get(b)) {​
buf.append((char) b);​
} else if (b == 32) {​
buf.append("%20");​
} else {​
buf.append("%");​
char hex1 = CONST_ENCODE.charAt(b >> 4);​
char hex2 = CONST_ENCODE.charAt(b & 15);​
buf.append(hex1);​
buf.append(hex2);​
}​
}​
​
return buf.toString();​
}​
​
public static String hashSHA256(byte[] content) throws Exception {​
try {​
MessageDigest md = MessageDigest.getInstance("SHA-256");​
​
return HexFormat.of().formatHex(md.digest(content));​
} catch (Exception e) {​
throw new Exception(​
"Unable to compute hash while signing request: "​
+ e.getMessage(), e);​
}​
}​
​
public static byte[] hmacSHA256(byte[] key, String content) throws Exception {​
try {​
Mac mac = Mac.getInstance("HmacSHA256");​
mac.init(new SecretKeySpec(key, "HmacSHA256"));​
return mac.doFinal(content.getBytes());​
} catch (Exception e) {​
throw new Exception(​
"Unable to calculate a request signature: "​
+ e.getMessage(), e);​
}​
}​
​
private byte[] genSigningSecretKeyV4(String secretKey, String date, String region, String service) throws Exception {​
byte[] kDate = hmacSHA256((secretKey).getBytes(), date);​
byte[] kRegion = hmacSHA256(kDate, region);​
byte[] kService = hmacSHA256(kRegion, service);​
return hmacSHA256(kService, "request");​
}​
}​
​
​
Golang​
​
package main​
​
import (​
"bytes"​
"crypto/hmac"​
"crypto/sha256"​
"encoding/hex"​
"encoding/json"​
"fmt"​
"log"​
"net/http"​
"net/http/httputil"​
"net/url"​
"strings"​
"time"​
)​
​
const (​
// 请求凭证,从访问控制申请​
AccessKeyID = ""​
SecretAccessKey = ""​
​
// 请求地址​
Addr = "https://visual.volcengineapi.com"​
Path = "/" // 路径,不包含 Query​
​
// 请求接口信息​
ServiceName = "cv"​
Region = "cn-north-1"​
Action = "LumiSync2AsyncSubmitTask"​
Version = "2025-06-01"​
)​
​
func hmacSHA256(key []byte, content string) []byte {​
mac := hmac.New(sha256.New, key)​
mac.Write([]byte(content))​
return mac.Sum(nil)​
}​
​
func getSignedKey(secretKey, date, region, service string) []byte {​
kDate := hmacSHA256([]byte(secretKey), date)​
kRegion := hmacSHA256(kDate, region)​
kService := hmacSHA256(kRegion, service)​
kSigning := hmacSHA256(kService, "request")​
​
return kSigning​
}​
​
func hashSHA256(data []byte) []byte {​
hash := sha256.New()​
if _, err := hash.Write(data); err != nil {​
log.Printf("input hash err:%s", err.Error())​
}​
​
return hash.Sum(nil)​
}​
​
func doRequest(method string, queries url.Values, body []byte) error {​
// 1. 构建请求​
queries.Set("Action", Action)​
queries.Set("Version", Version)​
requestAddr := fmt.Sprintf("%s?%s", Addr, queries.Encode())​
log.Printf("request addr: %s\n", requestAddr)​
​
request, err := http.NewRequest(method, requestAddr, bytes.NewBuffer(body))​
if err != nil {​
return fmt.Errorf("bad request: %w", err)​
}​
​
// 2. 构建签名材料​
now := time.Now()​
date := now.UTC().Format("20060102T150405Z")​
authDate := date[:8]​
request.Header.Set("X-Date", date)​
​
payload := hex.EncodeToString(hashSHA256(body))​
request.Header.Set("X-Content-Sha256", payload)​
request.Header.Set("Content-Type", "application/json")​
​
queryString := strings.Replace(queries.Encode(), "+", "%20", -1)​
signedHeaders := []string{"host", "x-date", "x-content-sha256", "content-type"}​
var headerList []string​
for _, header := range signedHeaders {​
if header == "host" {​
headerList = append(headerList, header+":"+request.Host)​
} else {​
v := request.Header.Get(header)​
headerList = append(headerList, header+":"+strings.TrimSpace(v))​
}​
}​
headerString := strings.Join(headerList, "\n")​
​
canonicalString := strings.Join([]string{​
method,​
Path,​
queryString,​
headerString + "\n",​
strings.Join(signedHeaders, ";"),​
payload,​
}, "\n")​
log.Printf("canonical string:\n%s\n", canonicalString)​
​
hashedCanonicalString := hex.EncodeToString(hashSHA256([]byte(canonicalString)))​
log.Printf("hashed canonical string: %s\n", hashedCanonicalString)​
​
credentialScope := authDate + "/" + Region + "/" + ServiceName + "/request"​
signString := strings.Join([]string{​
"HMAC-SHA256",​
date,​
credentialScope,​
hashedCanonicalString,​
}, "\n")​
log.Printf("sign string:\n%s\n", signString)​
​
// 3. 构建认证请求头​
signedKey := getSignedKey(SecretAccessKey, authDate, Region, ServiceName)​
signature := hex.EncodeToString(hmacSHA256(signedKey, signString))​
log.Printf("signature: %s\n", signature)​
​
authorization := "HMAC-SHA256" +​
" Credential=" + AccessKeyID + "/" + credentialScope +​
", SignedHeaders=" + strings.Join(signedHeaders, ";") +​
", Signature=" + signature​
request.Header.Set("Authorization", authorization)​
log.Printf("authorization: %s\n", authorization)​
​
// 4. 打印请求,发起请求​
requestRaw, err := httputil.DumpRequest(request, true)​
if err != nil {​
return fmt.Errorf("dump request err: %w", err)​
}​
​
log.Printf("request:\n%s\n", string(requestRaw))​
​
response, err := http.DefaultClient.Do(request)​
if err != nil {​
return fmt.Errorf("do request err: %w", err)​
}​
defer response.Body.Close()​
​
// 5. 读取响应内容并进行替换​
responseRaw, err := httputil.DumpResponse(response, true)​
if err != nil {​
return fmt.Errorf("dump response err: %w", err)​
}​
responseStr := string(responseRaw)​
responseStr = strings.ReplaceAll(responseStr, `\u0026`, `&`)​
​
log.Printf("response:\n%s\n", responseStr)​
​
if response.StatusCode == 200 {​
log.Printf("请求成功")​
} else {​
log.Printf("请求失败")​
}​
​
return nil​
}​
​
func main() {​
// Post json例子​
query := make(url.Values)​
// 新增req_json嵌套对象,包含text字段​
jsonBody := map[string]interface{}{​
"req_key": "lumi_ty_t2v_test",​
"res_quota_name": "Untitle",​
"req_json": map[string]interface{}{​
"text": "生成一个小孩在田野里放风筝",​
},​
}​
​
jsonByte, err := json.Marshal(jsonBody)​
if err != nil {​
log.Fatalf("json marshal err: %s", err.Error())​
}​
_ = doRequest("POST", query, jsonByte)​
}​
​
Python​
​
# coding:utf-8​
"""​
Copyright (year) Beijing Volcano Engine Technology Ltd.​
​
Licensed under the Apache License, Version 2.0 (the "License");​
you may not use this file except in compliance with the License.​
You may obtain a copy of the License at​
​
http://www.apache.org/licenses/LICENSE-2.0​
​
Unless required by applicable law or agreed to in writing, software​
distributed under the License is distributed on an "AS IS" BASIS,​
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.​
See the License for the specific language governing permissions and​
limitations under the License.​
"""​
​
import datetime​
import hashlib​
import hmac​
import json​
import os​
from pprint import pprint​
from urllib.parse import quote​
​
import requests​
​
# 以下参数视服务不同而不同,一个服务内通常是一致的​
Service = "cv"​
Version = "2025-06-01"​
Region = "cn-north-1"​
Host = "visual.volcengineapi.com"​
ContentType = "application/json"​
AK = ""​
SK = "=="​
​
​
# 当使用临时凭证时,需要使用到SessionToken传入Header,并计算进SignedHeader中,请自行在header参数中添加X-Security-Token头​
# SessionToken = ""​
​
​
def norm_query(params):​
query = ""​
for key in sorted(params.keys()):​
value = params[key]​
if type(value) == list:​
for k in value:​
str_k = str(k)​
query = (​
query + quote(key, safe="-_.~") + "=" + quote(str_k, safe="-_.~") + "&"​
)​
else:​
str_value = str(value)​
query = (query + quote(key, safe="-_.~") + "=" + quote(str_value, safe="-_.~") + "&")​
if query:​
query = query[:-1]​
return query.replace("+", "%20")​
​
​
# 第一步:准备辅助函数。​
# sha256 非对称加密​
def hmac_sha256(key: bytes, content: str):​
return hmac.new(key, content.encode("utf-8"), hashlib.sha256).digest()​
​
​
# sha256 hash算法​
def hash_sha256(content: str):​
return hashlib.sha256(content.encode("utf-8")).hexdigest()​
​
​
# 第二步:签名请求函数​
def request(method, date, query, header, ak, sk, action, body):​
# 第三步:创建身份证明。其中的 Service 和 Region 字段是固定的。ak 和 sk 分别代表​
# AccessKeyID 和 SecretAccessKey。同时需要初始化签名结构体。一些签名计算时需要的属性也在这里处理。​
# 初始化身份证明结构体​
credential = {​
"access_key_id": ak,​
"secret_access_key": sk,​
"service": Service,​
"region": Region,​
}​
# 初始化签名结构体​
request_param = {​
"body": body,​
"host": Host,​
"path": "/",​
"method": method,​
"content_type": ContentType,​
"date": date,​
"query": {"Action": action, "Version": Version, **query},​
}​
if body is None:​
request_param["body"] = ""​
# 第四步:接下来开始计算签名。在计算签名前,先准备好用于接收签算结果的 signResult 变量,并设置一些参数。​
# 初始化签名结果的结构体​
x_date = request_param["date"].strftime("%Y%m%dT%H%M%SZ")​
short_x_date = x_date[:8]​
x_content_sha256 = hash_sha256(request_param["body"])​
sign_result = {​
"Host": request_param["host"],​
"X-Content-Sha256": x_content_sha256,​
"X-Date": x_date,​
"Content-Type": request_param["content_type"],​
}​
# 第五步:计算 Signature 签名。​
signed_headers_str = ";".join(​
["content-type", "host", "x-content-sha256", "x-date"]​
)​
# signed_headers_str = signed_headers_str + ";x-security-token"​
canonical_request_str = "\n".join(​
[request_param["method"].upper(),​
request_param["path"],​
norm_query(request_param["query"]),​
"\n".join(​
[​
"content-type:" + request_param["content_type"],​
"host:" + request_param["host"],​
"x-content-sha256:" + x_content_sha256,​
"x-date:" + x_date,​
]​
),​
"",​
signed_headers_str,​
x_content_sha256,​
]​
)​
​
# 打印正规化的请求用于调试比对​
print(canonical_request_str)​
hashed_canonical_request = hash_sha256(canonical_request_str)​
​
# 打印hash值用于调试比对​
print(hashed_canonical_request)​
credential_scope = "/".join([short_x_date, credential["region"], credential["service"], "request"])​
string_to_sign = "\n".join(["HMAC-SHA256", x_date, credential_scope, hashed_canonical_request])​
​
# 打印最终计算的签名字符串用于调试比对​
print(string_to_sign)​
k_date = hmac_sha256(credential["secret_access_key"].encode("utf-8"), short_x_date)​
k_region = hmac_sha256(k_date, credential["region"])​
k_service = hmac_sha256(k_region, credential["service"])​
k_signing = hmac_sha256(k_service, "request")​
signature = hmac_sha256(k_signing, string_to_sign).hex()​
​
sign_result["Authorization"] = "HMAC-SHA256 Credential={}, SignedHeaders={}, Signature={}".format(​
credential["access_key_id"] + "/" + credential_scope,​
signed_headers_str,​
signature,​
)​
header = {**header, **sign_result}​
# 如需使用临时凭证,请取消下面这行注释​
# header = {**header, **{"X-Security-Token": SessionToken}}​
​
# 第六步:将 Signature 签名写入 HTTP Header 中,并发送 HTTP 请求。​
try:​
r = requests.request(​
method=method,​
url="https://{}{}".format(request_param["host"], request_param["path"]),​
headers=header,​
params=request_param["query"],​
data=request_param["body"],​
)​
​
# 先打印原始响应内容,方便调试​
# print("原始响应内容:", r.text)​
​
# 尝试解析JSON​
try:​
return r.json()​
except json.JSONDecodeError:​
# 如果解析失败,返回包含状态码和原始内容的字典​
return {​
"status_code": r.status_code,​
"text": r.text,​
"error": "Invalid JSON response"​
}​
except Exception as e:​
print("请求发生异常:", str(e))​
return {"error": str(e)}​
​
​
if __name__ == "__main__":​
now = datetime.datetime.utcnow()​
# json格式数据,根据API要求填写实际参数​
data = {​
"req_key": "lumi_ty_t2v_test",​
"res_quota_name": "Untitle",​
​
"req_json": {​
"text": "美女在海边玩耍",​
}​
}​
​
data = json.dumps(data)​
response_body = request("POST", now, {}, {}, AK, SK, "LumiSync2AsyncSubmitTask", body=data)​
print(response_body)​
​
PHP​
​
<?php​
/**​
* Copyright (year) Beijing Volcano Engine Technology Ltd.​
*​
* Licensed under the Apache License, Version 2.0 (the "License");​
* you may not use this file except in compliance with the License.​
* You may obtain a copy of the License at​
*​
* http://www.apache.org/licenses/LICENSE-2.0​
*​
* Unless required by applicable law or agreed to in writing, software​
* distributed under the License is distributed on an "AS IS" BASIS,​
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.​
* See the License for the specific language governing permissions and​
* limitations under the License.​
*/​
​
require '../vendor/autoload.php';​
​
// 需要自行安装 composer(https://getcomposer.org/doc/00-intro.md),并安装GuzzleHttp依赖, composer require guzzlehttp/guzzle:^7.0​
use GuzzleHttp\Client;​
use GuzzleHttp\Exception\GuzzleException;​
​
​
$ServiceName = "cv";​
$Version = "2025-06-01";​
$Region = "cn-north-1";​
$Host = "visual.volcengineapi.com";​
$ContentType = "application/json";​
/**​
* @throws GuzzleException​
*/​
// 第一步:创建一个 API 请求函数。签名计算的过程包含在该函数中。​
function request($method, $query, $header, $ak, $sk, $action, $body)​
{​
​
// 第二步:创建身份证明。其中的 Service 和 Region 字段是固定的。ak 和 sk 分别代表​
// AccessKeyID 和 SecretAccessKey。同时需要初始化签名结构体。一些签名计算时需要的属性也在这里处理。​
// 初始化身份证明结构体​
global $ServiceName, $Region, $Host, $Version, $ContentType;​
$credential = [​
'accessKeyId' => $ak,​
'secretKeyId' => $sk,​
'service' => $ServiceName,​
'region' => $Region,​
];​
​
// 初始化签名结构体​
$query = array_merge($query, [​
'Action' => $action,​
'Version' => $Version​
]);​
ksort($query);​
$requestParam = [​
// body是http请求需要的原生body​
'body' => $body,​
'host' => $Host,​
'path' => '/',​
'method' => $method,​
'contentType' => $ContentType,​
'date' => gmdate('Ymd\THis\Z'),​
'query' => $query​
];​
​
// 第三步:接下来开始计算签名。在计算签名前,先准备好用于接收签算结果的 signResult 变量,并设置一些参数。​
// 初始化签名结果的结构体​
$xDate = $requestParam['date'];​
$shortXDate = substr($xDate, 0, 8);​
$xContentSha256 = hash('sha256', $requestParam['body']);​
$signResult = [​
'Host' => $requestParam['host'],​
'X-Content-Sha256' => $xContentSha256,​
'X-Date' => $xDate,​
'Content-Type' => $requestParam['contentType']​
];​
// 第四步:计算 Signature 签名。​
$signedHeaderStr = join(';', ['content-type', 'host', 'x-content-sha256', 'x-date']);​
$canonicalRequestStr = join("\n", [​
$requestParam['method'],​
$requestParam['path'],​
http_build_query($requestParam['query']),​
join("\n", ['content-type:' . $requestParam['contentType'], 'host:' . $requestParam['host'], 'x-content-sha256:' . $xContentSha256, 'x-date:' . $xDate]),​
'',​
$signedHeaderStr,​
$xContentSha256​
]);​
$hashedCanonicalRequest = hash("sha256", $canonicalRequestStr);​
$credentialScope = join('/', [$shortXDate, $credential['region'], $credential['service'], 'request']);​
$stringToSign = join("\n", ['HMAC-SHA256', $xDate, $credentialScope, $hashedCanonicalRequest]);​
$kDate = hash_hmac("sha256", $shortXDate, $credential['secretKeyId'], true);​
$kRegion = hash_hmac("sha256", $credential['region'], $kDate, true);​
$kService = hash_hmac("sha256", $credential['service'], $kRegion, true);​
$kSigning = hash_hmac("sha256", 'request', $kService, true);​
$signature = hash_hmac("sha256", $stringToSign, $kSigning);​
$signResult['Authorization'] = sprintf("HMAC-SHA256 Credential=%s, SignedHeaders=%s, Signature=%s", $credential['accessKeyId'] . '/' . $credentialScope, $signedHeaderStr, $signature);​
$header = array_merge($header, $signResult);​
// 第五步:将 Signature 签名写入 HTTP Header 中,并发送 HTTP 请求。​
$client = new Client([​
'base_uri' => 'https://' . $requestParam['host'],​
'timeout' => 120.0,​
]);​
return $client->request($method, 'https://' . $requestParam['host'] . $requestParam['path'], [​
'headers' => $header,​
'query' => $requestParam['query'],​
'body' => $requestParam['body']​
]);​
}​
​
$now = time();​
​
$requestBody = [​
'req_key' => 'lumi_ty_t2v_test',​
'res_quota_name' => 'Untitle',​
"req_json"=> [​
"text"=> "美女在海边玩耍",​
]​
];​
​
$body = json_encode($requestBody);​
//print $body;​
$AK = '';​
$SK = '';​
​
try {​
$response = request("POST", [], [], $AK, $SK, "LumiSync2AsyncSubmitTask", $body);​
// 获取响应内容并替换\u0026为&​
$responseBody = $response->getBody()->getContents();​
$formattedBody = str_replace('\u0026', '&', $responseBody);​
print_r($formattedBody);​
} catch (GuzzleException $e) {​
print_r($e->getMessage());​
}​
​
​
最近更新时间:2026.08.18 20:07:14
这个页面对您有帮助吗?
有用
有用
无用
无用