Skip to content

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
}

响应参数 ​

参数名类型说明
codestring1000 成功;其他值都是失败,通常是 1001
messagestring反馈信息
dataobjectCDN 视频信息
data.cdnUrlstring视频 CDN 信息
data.aesKeystring视频 aesKey
data.lengthnumber视频文件大小或长度字段,按接口返回值使用