在线调试
填写业务相关参数免费在线调试
会员->单独包月->次数包->点数计费->账户余额->免费额度
支持点数余额抵扣,每次扣除点数:320 点/次 约 0.32 元/次
免费/测试用户请求频率限制 | 请求频率总限制 | 每日请求次数总限制 |
---|---|---|
0秒0次 每个免费用户的QPS总限制 | 1秒1次 每个用户QPS总限制 | 10000 (次) 每个用户每日请求总次数 |
接口地址:https://duomiapi.com/api/video/runway/pro/video2video
返回格式:application/json
请求方式:HTTPPOST
请求示例:请求
Introduction 介绍
Gen-3 Alpha is the first of upcoming models that offers improvement in fidelity, consistency, motion and speed over previous generations of models.
Gen-3 Alpha 是即将推出的首款型号,与前几代型号相比,它在保真度、一致性、运动和速度方面都有所改进。
Video to Video allows you to change the style of your videos by using a text prompt.
Video to Video 允许您使用文本提示更改视频的样式。
This article outlines how to use Video to Video on Gen-3 Alpha, the available settings and more.
本文概述了如何在 Gen-3 Alpha 上使用 Video to Video、可用设置等。
Spec Information 规格信息
Cost 成本 5 seconds or less: 50 credits
5 秒或更短:50 个积分
Longer than 5 seconds: 100 credits
超过 5 秒:100 个积分
Supported durations 支持的持续时间 Up to 10 seconds 长达 10 秒
Explore Mode on Unlimited Plans
无限计划的探索模式 Yes 是的
Platform availability 平台可用性 Web 蹼
Supported video inputs 支持的视频输入 See here 看这里
Output resolution 输出分辨率 SD (720p) 标清 (720p)
Supported aspect ratios 支持的纵横比 16:9 (1280x768) 16:9 (1280x768)
Maximum input size 最大输入大小 64mb 64兆字节(MB)
Step 1 – Selecting the Input Video
第 1 步 – 选择输入视频
Begin by navigating to Generative Video in your Dashboard.
首先导航到 Dashboard 中的 Generative Video(生成视频)。
From here, make sure the Gen-3 Alpha model is selected in the top left corner dropdown. Video to Video is only available on the full Gen-3 Alpha model, meaning you won't have the option to upload a video on the Turbo model.
从这里,确保在左上角下拉列表中选择 Gen-3 Alpha 模型。视频到视频仅适用于完整的 Gen-3 Alpha 型号,这意味着您将无法选择在 Turbo 型号上上传视频。
Select a supported video file from your assets or drag and drop a video to upload it.
从您的资产中选择受支持的视频文件,或拖放视频以上传它。
Video to Video currently supports 16:9 aspect ratios. If using a video in a different aspect ratio, you’ll be prompted to crop the video into the supported 16:9 format.
视频到视频目前支持 16:9 的纵横比。如果使用不同纵横比的视频,系统将提示您将视频裁剪为支持的 16:9 格式。
Credit notes 贷方票据
When choosing a video, please note that credits are charged based on the length of your input:
选择视频时,请注意,积分将根据您的输入长度收费:
≤ 5 seconds: 50 credits
≤ 5 秒:50 积分
> 5 seconds: 100 credits
> 5 秒:100 积分
We recommend choosing videos in 5 or 10 second durations for optimized credit usage. Videos longer than 10 seconds will be automatically trimmed to the first 10 seconds of the input.
我们建议选择 5 秒或 10 秒时长的视频,以优化积分使用。超过 10 秒的视频将自动修剪到输入的前 10 秒。
Step 2 – Drafting the Prompt
第 2 步 – 起草提示
Video to Video can dramatically change the style of your input with a strong text prompt. A descriptive prompt that focuses on the desired style will provide the best results in most cases.
视频到视频可以通过强文本提示显著改变输入的样式。在大多数情况下,专注于所需样式的描述性提示将提供最佳结果。
This tutorial uses an example with a green screen mask, but you can use any type of video input.
本教程使用具有绿屏蒙版的示例,但您可以使用任何类型的视频输入。
Input 输入 Prompt 提示 Output 输出
3D halftone CMYK style. halftone print dot. comic book. vibrant colors in layers of cyan blue, yellow, magenta purple, and black circular dots.
3D 半调 CMYK 样式。半色调印花点。漫画。青蓝色、黄色、洋红色紫色和黑色圆点层中的鲜艳色彩。
Tip: Try out a Custom Preset to load a curated example prompt. Be sure to replace the purple placeholder text with any customizations you wish to include.
提示:尝试 Custom Preset 以加载精选的示例提示。请务必将紫色占位符文本替换为您希望包含的任何自定义项。
Simple prompts tend to work well, but detailed prompts are more effective and will yield results more closely aligned with the concept you’re envisioning.
简单的提示往往效果很好,但详细的提示更有效,并且会产生更符合您设想的概念的结果。
Step 3 – Configuring the Settings
第 3 步 – 配置设置
Video to Video has additional settings that you should review before starting your generation.
Video to Video 具有其他设置,您应该在开始生成之前查看这些设置。
Structure transformation 结构改造
This setting controls the structural consistency between the input and output. Lower values will result in an output that maintains the structure of the original video. Higher values will result in more abstract outputs.
此设置控制输入和输出之间的结构一致性。较低的值将导致输出保持原始视频的结构。值越高,输出越抽象。
Structure transformation value
结构变换值 Output 输出
0.00
0.50
1.00
Remove watermark 去除水印
Checking this box will remove the Runway watermark from your output. Make sure this box is checked to generate without watermarks.
选中此框将从您的输出中删除 Runway 水印。确保选中此框以生成无水印。
Fixed seed 固定种子
Using a fixed seed will allow you to create similar generations. This is unchecked by default to give you a wide variety of results.
使用固定种子将允许您创建相似的代。默认情况下,此选项处于未选中状态,可为您提供各种各样的结果。
Copy and paste the seed of a previous output if you'd like to receive generations with similar style and movement. Pasting the seed will automatically check the box.
如果您想接收具有相似样式和动作的世代,请复制并粘贴先前输出的种子。粘贴种子将自动选中该框。
Step 4 – Generating the Video
第 4 步 – 生成视频
After drafting your text prompt and configuring your settings, you're now ready to generate your video.
在起草文本提示并配置设置后,您现在可以生成视频了。
The final result will match the length of the input video if it's 10 seconds or less. For videos longer than 10 seconds, only the first 10 seconds will be used.
如果输入视频的长度为 10 秒或更短,则最终结果将与输入视频的长度匹配。对于时长超过 10 秒的视频,系统只会使用前 10 秒。
Your generations will be scrollable through your session as you continue to generate. You can also access completed videos in your Assets, where they will save to the Generative Video folder by default.
随着您继续生成,您的世代将可滚动浏览您的会话。您还可以在 Assets 中访问已完成的视频,默认情况下,它们将保存到 Generative Video 文件夹中。
{
"code": 200,
"msg": "成功",
"data": {
"task_id": "0ab3bfe2-be23-4635-8c35-890fb2c1732d"
},
"exec_time": 0.67573,
"ip": "171.214.61.54"
}
<?php
/**
* API请求DEMO
*
* 本demo支持常见的HTTP请求方法(GET/POST/PUT/DELETE等)
*/
//基本配置
$api_key = '你的接口密钥,登录控制台后在密钥管理页面申请';
$secret_key = '';
// API请求示例:
try {
$client = new ApiClient($api_key, $secret_key);
$client->setTimeout(10);
$client->setVerifySSL(false); // 关闭SSL验证
// GET请求示例
echo "=== 开始GET请求 ===\n";
$response = $client->get('https://duomiapi.com/api/video/runway/pro/video2video', [
'key' => $api_key,
'key2' => '其他参数'
]);
print_r($response);
//print_r($client->getLastRequestInfo());
/*
// POST表单示例
echo "\n=== 开始POST请求 ===\n";
$response = $client->post('接口地址', [
'key' => $api_key,
'key2' => '其他参数'
]);
print_r($response);
print_r($client->getLastRequestInfo());
// POST JSON示例
echo "\n=== 开始POST JSON请求 ===\n";
$response = $client->postJson('接口地址', [
'key' => $api_key,
'key2' => '其他参数'
]);
print_r($response);
print_r($client->getLastRequestInfo());
*/
} catch (ApiClientException $e) {
echo "API请求错误: " . $e->getMessage();
if ($e->getCode() > 0) {
echo " (HTTP状态码: " . $e->getCode() . ")";
}
print_r($client->getLastRequestInfo() ?? []);
}
/**
* API客户端类
*
* 提供了一个简单的HTTP API客户端实现,支持常见的HTTP请求方法(GET/POST/PUT/DELETE等)
* 具有以下主要功能:
* - 支持 API 密钥和签名认证
* - 可配置请求超时和SSL验证
* - 支持自定义请求头
* - 支持表单和JSON格式的请求体
* - 自动解析响应结果
* - 提供详细的请求信息记录
*
* 使用示例:
* ```
* $client = new ApiClient('https://api.example.com', 'api_key', 'secret_key');
* $response = $client->get('/users', ['page' => 1]);
* ```
*
* @throws ApiClientException 当API请求失败时抛出异常
*/
class ApiClient
{
private $apiKey;
private $secretKey;
private $timeout = 30;
private $verifySSL = true;
private $lastRequestInfo = [];
private $defaultHeaders = [];
/**
* 构造函数
*
* @param string $apiKey API密钥(可选)
* @param string $secretKey 签名密钥(可选)
*/
public function __construct(string $apiKey = '', string $secretKey = '')
{
$this->apiKey = $apiKey;
$this->secretKey = $secretKey;
}
/**
* 设置请求超时时间(秒)
*/
public function setTimeout(int $seconds): self
{
$this->timeout = $seconds;
return $this;
}
/**
* 设置是否验证SSL证书
*/
public function setVerifySSL(bool $verify): self
{
$this->verifySSL = $verify;
return $this;
}
/**
* 添加默认请求头
*/
public function addDefaultHeader(string $name, string $value): self
{
$this->defaultHeaders[$name] = $value;
return $this;
}
/**
* 发送GET请求
*
* @param string $endpoint 接口端点
* @param array $query 查询参数
* @param array $headers 额外请求头
*/
public function get(string $endpoint, array $query = [], array $headers = []): array
{
return $this->request('GET', $endpoint, [
'query' => $query,
'headers' => $headers
]);
}
/**
* 发送POST请求(表单格式)
*
* @param string $endpoint 接口端点
* @param array $data POST数据
* @param array $headers 额外请求头
*/
public function post(string $endpoint, array $data = [], array $headers = []): array
{
return $this->request('POST', $endpoint, [
'form_data' => $data,
'headers' => $headers
]);
}
/**
* 发送POST请求(JSON格式)
*
* @param string $endpoint 接口端点
* @param array $data POST数据
* @param array $headers 额外请求头
*/
public function postJson(string $endpoint, array $data = [], array $headers = []): array
{
return $this->request('POST', $endpoint, [
'json' => $data,
'headers' => array_merge(['Content-Type' => 'application/json'], $headers)
]);
}
/**
* 发送PUT请求
*/
public function put(string $endpoint, array $data = [], array $headers = []): array
{
return $this->request('PUT', $endpoint, [
'json' => $data,
'headers' => $headers
]);
}
/**
* 发送DELETE请求
*/
public function delete(string $endpoint, array $data = [], array $headers = []): array
{
return $this->request('DELETE', $endpoint, [
'json' => $data,
'headers' => $headers
]);
}
/**
* 获取最后一次请求的详细信息
*/
public function getLastRequestInfo(): array
{
return $this->lastRequestInfo;
}
/**
* 基础请求方法
*/
private function request(string $method, string $endpoint, array $options = []): array
{
// 初始化cURL
$ch = curl_init();
$url = ltrim($endpoint, '/');
// 准备请求头
$headers = $this->prepareHeaders($options['headers'] ?? []);
// 处理查询参数
if (!empty($options['query'])) {
$url .= '?' . http_build_query($options['query']);
}
// 处理请求体
$postData = null;
if (isset($options['form_data'])) {
$postData = http_build_query($options['form_data']);
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
} elseif (isset($options['json'])) {
$postData = json_encode($options['json']);
$headers[] = 'Content-Type: application/json';
}
// 设置cURL选项
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_TIMEOUT => $this->timeout,
CURLOPT_SSL_VERIFYPEER => $this->verifySSL,
CURLOPT_SSL_VERIFYHOST => $this->verifySSL,
CURLOPT_HEADER => true,
]);
if ($method !== 'GET' && $postData !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
}
// 执行请求
$response = curl_exec($ch);
$error = curl_error($ch);
$info = $this->lastRequestInfo = curl_getinfo($ch);
curl_close($ch);
// 处理错误
if ($error) {
throw new ApiClientException("cURL请求失败: " . $error);
}
// 分离响应头和响应体
$headerSize = $info['header_size'];
$responseHeaders = substr($response, 0, $headerSize);
$responseBody = substr($response, $headerSize);
// 解析响应
$result = json_decode($responseBody, true) ?? $responseBody;
// 检查HTTP状态码
if ($info['http_code'] >= 400) {
$errorMsg = is_array($result) ? ($result['message'] ?? $responseBody) : $responseBody;
throw new ApiClientException("API请求失败: " . $errorMsg, $info['http_code']);
}
return [
'status' => $info['http_code'],
'headers' => $this->parseHeaders($responseHeaders),
'data' => $result
];
}
/**
* 准备请求头(自动添加签名)
*/
private function prepareHeaders(array $headers): array
{
// 合并默认头
$headers = array_merge($this->defaultHeaders, $headers);
// 添加签名头
if ($this->apiKey && $this->secretKey) {
$timestamp = time();
$signString = "key={$this->apiKey}×tamp={$timestamp}";
$signature = hash_hmac('sha256', $signString, $this->secretKey);
$headers['X-Api-Key'] = $this->apiKey;
$headers['X-Api-Timestamp'] = $timestamp;
$headers['X-Api-Sign'] = $signature;
}
// 转换为cURL格式
$curlHeaders = [];
foreach ($headers as $name => $value) {
$curlHeaders[] = "$name: $value";
}
return $curlHeaders;
}
/**
* 解析响应头
*/
private function parseHeaders(string $headers): array
{
$parsed = [];
foreach (explode("\r\n", $headers) as $i => $line) {
if ($i === 0) {
$parsed['HTTP_CODE'] = $line;
} else {
$parts = explode(': ', $line, 2);
if (count($parts) === 2) {
$parsed[$parts[0]] = $parts[1];
}
}
}
return $parsed;
}
}
class ApiClientException extends \Exception
{
// 自定义异常类
}
//jQuery-Ajax
$.ajax({
url: 'https://duomiapi.com/api/video/runway/pro/video2video',
data: {
//接口参数,一行一个,可按照接口文档-请求参数 的参数填写,或者直接复制开发工具下面的测试代码。
key: '你的接口密钥,登录控制台后在密钥管理页面申请',
参数名: '参数值',
},
type: 'GET', //请求协议(GET或POST),一般默认GET,部分接口需要POST请求,根据实际情况修改为POST即可。
dataType: 'json',
success: function(data) {
console.log(data); //请求成功,输出结果到控制台
},
timeout: 3000, //超时时间
error: function(data) {
console.log('请求失败'); //失败处理
}
});
子程序名 | 返回值类型 | 公开 | 备 注 | ||
__启动窗口_创建完毕 |
子程序名 | 返回值类型 | 公开 | 备 注 | ||
Send_API |
变量名 | 类 型 | 静态 | 数组 | 备 注 | ||
REQU_Data | 文本型 | 提交字符串 | ||||
return | 文本型 | 返回字符串 | ||||
API_URL | 文本型 | 接口地址 | ||||
API_KEY | 文本型 | 接口密钥 |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Test {
public static void main(String[] args) {
try {
URL url = new URL("https://duomiapi.com/api/video/runway/pro/video2video?key=你的接口密钥,登录控制台后在密钥管理页面申请");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
// 设置请求方式
connection.setRequestMethod("GET");
connection.connect();
// 获取响应码
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
// 读取到的内容给line变量
System.out.println(line);
}
reader.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
// 发起一个GET请求
resp, err := http.Get("https://duomiapi.com/api/video/runway/pro/video2video?key=你的接口密钥,登录控制台后在密钥管理页面申请")
if err != nil {
fmt.Println("http get error", err)
return
}
// 读取响应结果
result, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("http read error", err)
return
}
// 关闭响应结果
defer resp.Body.Close()
fmt.Println(string(result))
}
```
# 导入requests库
import requests
# 设置url
url = 'https://duomiapi.com/api/video/runway/pro/video2video?key=你的接口密钥,登录控制台后在密钥管理页面申请'
# 发送post请求
response = requests.post(url, data={'key1': 'value1', 'key2': 'value2'})
# 获取响应内容
result = response.json()
# 打印结果
print(result)
```
// 以下是使用Node.js进行GET和POST请求API接口的示例代码:
const https = require('https');
const querystring = require('querystring');
// 定义请求选项
const options = {
hostname: 'duomiapi.com',
path: '/api/video/runway/pro/video2video',
method: 'GET'
};
// 发送GET请求
https.get(options, res => {
console.log(`statusCode: ${res.statusCode}`);
res.on('data', d => {
process.stdout.write(d);
});
}).on('error', error => {
console.error(error);
});
// 发送POST请求
const postData = querystring.stringify({
'key1': 'value1',
'key2': 'value2'
});
const postOptions = {
hostname: 'duomiapi.com',
path: '/api/video/runway/pro/video2video',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(postData)
}
};
const postReq = https.request(postOptions, res => {
console.log(`statusCode: ${res.statusCode}`);
res.on('data', d => {
process.stdout.write(d);
});
});
postReq.on('error', error => {
console.error(error);
});
postReq.write(postData);
postReq.end();
/*
这个示例代码使用Node.js内置的`https`模块进行HTTP请求。
首先定义了一个GET请求的选项,然后使用`https.get()`方法发送了GET请求。在响应流上注册回调函数,以便在收到响应数据时将其输出到控制台。在出现错误时,也注册了错误处理程序。
类似地,我们也定义了一个POST请求选项,并使用`https.request()`方法发送它。需要在请求头中包含适当的`Content-Type`和`Content-Length`以确保服务器可以正确解析请求体。请求体由`write()`方法写入,并在请求结束时通过调用`end()`方法通知请求对象已经完成。
注意,此示例默认使用`querystring`模块将数据作为x-www-form-urlencoded格式进行编码。如果需要使用其他格式(如JSON),则需要相应地更改请求头和请求体的编码方式。
另外,为了确保HTTPS请求的安全性,您也可以添加其他选项,例如验证服务器证书、设置代理等。
*/
以下是使用C语言进行GET和POST请求API接口的示例代码:
``` c
#include
#include
#include
#include // 需要安装curl库
// API地址
const char* url = "https://duomiapi.com/api/video/runway/pro/video2video";
// GET请求
void getRequest(CURL* curl) {
CURLcode res;
// 设置URL
curl_easy_setopt(curl, CURLOPT_URL, url);
// 执行请求
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
}
}
// POST请求
void postRequest(CURL* curl) {
CURLcode res;
// 设置URL
curl_easy_setopt(curl, CURLOPT_URL, url);
// 设置POST数据
const char* postData = "key=你的接口密钥,登录控制台后在密钥管理页面申请&key1=value1";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData);
// 执行请求
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
}
}
int main() {
CURL* curl;
CURLcode res;
// 初始化curl
curl = curl_easy_init();
if(curl) {
// 设置SSL验证
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
// GET请求
getRequest(curl);
// POST请求
postRequest(curl);
// 清理curl资源
curl_easy_cleanup(curl);
}
return 0;
}
```
这个示例代码使用了libcurl库进行HTTP请求。
首先,需要设置API地址。然后,基于`CURL`结构体创建curl句柄,并使用`curl_easy_setopt()`函数设置选项。这里设置了SSL验证,以确保请求的安全性。
在GET请求中,只需将URL设置为选项,然后调用`curl_easy_perform()`函数执行请求即可。
在POST请求中,还需要将POST数据作为字符串传递给`CURLOPT_POSTFIELDS`选项。
需要注意的是,为了避免内存泄漏,应该在使用完curl句柄之后调用`curl_easy_cleanup()`函数进行清理。
除了上述示例代码外,libcurl库还提供了更多高级选项,例如处理HTTP头、上传文件等。可以参考文档进行更详细的了解。
以下是一个使用C++请求API接口的示例代码:
```cpp
#include
#include
int main() {
CURL *curl;
CURLcode res;
std::string url = "https://duomiapi.com/api/video/runway/pro/video2video?key=你的接口密钥,登录控制台后在密钥管理页面申请";
std::string response;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, [](char *ptr, size_t size, size_t nmemb, void *userdata) -> size_t {
std::string *response = reinterpret_cast(userdata);
response->append(ptr, size * nmemb);
return size * nmemb;
});
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
res = curl_easy_perform(curl);
if (res == CURLE_OK) {
std::cout << "Response: " << response << std::endl;
} else {
std::cerr << "Error: " << curl_easy_strerror(res) << std::endl;
}
curl_easy_cleanup(curl);
}
return 0;
}
```
解释:
1. 引入需要的头文件:``用于输出结果,``用于使用libcurl库。
2. 定义需要请求的API接口的URL和存储响应数据的字符串变量。
3. 初始化一个CURL对象。
4. 设置CURL对象的参数:请求的URL(`CURLOPT_URL`)、是否跟随重定向(`CURLOPT_FOLLOWLOCATION`)、响应数据的写入函数(`CURLOPT_WRITEFUNCTION`)和响应数据的写入位置(`CURLOPT_WRITEDATA`)。
5. 发送HTTP请求并获取响应数据,判断返回状态码是否OK。
6. 清理CURL对象。
运行该程序会发送GET请求到指定的API接口URL,并在程序终止前将响应数据输出到终端。注意,在使用该示例代码之前需要安装libcurl库。
以下是一个使用C#请求API接口的示例代码:
```csharp
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program {
static async Task Main(string[] args) {
HttpClient client = new HttpClient();
string url = "https://duomiapi.com/api/video/runway/pro/video2video?key=你的接口密钥,登录控制台后在密钥管理页面申请";
HttpResponseMessage response = await client.GetAsync(url);
if (response.IsSuccessStatusCode) {
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine("Response: " + responseBody);
} else {
Console.WriteLine("Error: " + response.StatusCode);
}
}
}
```
解释:
1. 引用需要的命名空间:`System.Net.Http`用于使用HttpClient类,`System.Threading.Tasks`用于异步执行请求操作。
2. 创建一个HttpClient对象。
3. 定义需要请求的API接口的URL。
4. 发送GET请求到指定的API接口URL,并获取响应结果。
5. 判断响应状态是否成功,如果成功则读取响应数据(使用ReadAsStringAsync方法),否则输出错误信息(使用StatusCode属性)。
运行该程序会发送GET请求到指定的API接口URL,并在程序终止前将响应数据输出到终端。注意,在使用该示例代码之前需要安装.NET Framework或.NET Core SDK。
以下是VB请求API接口的示例代码:
```
' 1. 引入Microsoft XML v6.0库
' 2. 创建一个XMLHTTP对象
Dim xhr As XMLHTTP
Set xhr = New XMLHTTP
' 3. 设置请求的URL、方法,以及是否异步等
xhr.Open "GET", "https://duomiapi.com/api/video/runway/pro/video2video?key=你的接口密钥,登录控制台后在密钥管理页面申请", False
' 4. 发送请求
xhr.send
' 5. 获取响应结果
Dim responseText As String
responseText = xhr.responseText
' 6. 输出响应结果
Debug.Print responseText
' 7. 释放资源
Set xhr = Nothing
```
在这个示例中,我们创建了一个XMLHTTP对象,用于请求API接口。我们先调用`open`方法来设置请求的URL、方法,以及是否异步。然后,我们发送请求,并使用`responseText`属性来获取响应结果。最后,我们将响应结果打印到控制台,完成操作后释放资源,以防止内存泄漏。请注意,以上示例代码为同步请求,如果想使用异步请求,需要设置第三个参数为`True`,并在请求结束时处理`OnReadyStateChange`事件。
参数名 | 填写参数值 |
---|---|
请 登录 后发表评论
填写业务相关参数免费在线调试
生成符合你的开发语言代码,复制即可
调整你后端部分逻辑代码即可上线使用
客服微信
joieme
请打开手机微信,扫一扫联系我们
返回顶部