Appearance
CDN 视频上传
把视频和封面上传到微信 CDN,返回发送视频消息要用的 cdnUrl、aesKey、length。
接口地址: POST /sendCdnVideo
说明与注意
path、thumbPath都要是接口服务能直接访问的 URL。
请求参数
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| wId | 是 | string | 登录实例标识 |
| path | 是 | string | 视频 URL |
| thumbPath | 是 | string | 视频封面图片 URL |
请求示例
http
POST {BASE_URL}/sendCdnVideo
Authorization: Bearer <你的调用凭证>
Content-Type: application/json
{
"wId": "{{wId}}",
"path": "https://cdn.e-yun.example/video/customer-case.mp4",
"thumbPath": "https://cdn.e-yun.example/video/customer-case-cover.png"
}bash
curl -X POST '{BASE_URL}/sendCdnVideo' \
-H 'Authorization: Bearer <你的调用凭证>' \
-H 'Content-Type: application/json' \
--data-raw '{
"wId": "{{wId}}",
"path": "https://cdn.e-yun.example/video/customer-case.mp4",
"thumbPath": "https://cdn.e-yun.example/video/customer-case-cover.png"
}'python
import requests
url = "{BASE_URL}/sendCdnVideo"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
"wId": "{{wId}}",
"path": "https://cdn.e-yun.example/video/customer-case.mp4",
"thumbPath": "https://cdn.e-yun.example/video/customer-case-cover.png"
}"""
resp = requests.post(url, headers=headers, data=body.encode("utf-8"))
print(resp.text)java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
String url = "{BASE_URL}/sendCdnVideo";
String body = "{\n" +
" \"wId\": \"{{wId}}\",\n" +
" \"path\": \"https://cdn.e-yun.example/video/customer-case.mp4\",\n" +
" \"thumbPath\": \"https://cdn.e-yun.example/video/customer-case-cover.png\"\n" +
"}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create(url))
.header("Authorization", "Bearer <你的调用凭证>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());php
<?php
$url = '{BASE_URL}/sendCdnVideo';
$body = <<<'JSON'
{
"wId": "{{wId}}",
"path": "https://cdn.e-yun.example/video/customer-case.mp4",
"thumbPath": "https://cdn.e-yun.example/video/customer-case-cover.png"
}
JSON;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer <你的调用凭证>',
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;成功响应
json
{
"code": "1000",
"message": "发送视频消息成功",
"data": {
"cdnUrl": "30670201000460305e02010002041b9042eb02033d14b90204...",
"aesKey": "1a8e3941e3cc233e6f151430088eec6e",
"length": 3124240
}
}错误响应
json
{
"code": "1001",
"message": "失败",
"data": null
}响应参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| code | string | 1000 成功;其他值都是失败,通常是 1001 |
| message | string | 反馈信息 |
| data | object | CDN 视频信息 |
| data.cdnUrl | string | 视频 CDN 信息 |
| data.aesKey | string | 视频 aesKey |
| data.length | number | 视频文件大小或长度字段,按接口返回值使用 |