调用方式
服务地址¶
环境 | 域名 |
---|---|
测试环境 | vod.test.mediacloud.imgo.tv |
线上环境 | vod.mediacloud.imgo.tv |
请求方法¶
支持的 HTTP 请求方法:
POST GET PUT DELETE
字符编码¶
均使用UTF-8编码。
请求成功示例¶
// WARNING: For POST requests, body is set to null by browsers.
var data = JSON.stringify({
"username": "your_username",
"password": "your_password"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "http://vod.test.mediacloud.imgo.tv/api/v1/login");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);
返回结果¶
{
"requestId": "023822cd-fc78-4d5f-be17-19132044ee8f",
"code": 200,
"msg": "登陆成功",
"data": {
"jwt": {
"access_token": "eyJhbGciOiJSUzI******************************sdfasd34jmkl3j4",
"id_token": "eyJhbGciOiJSUzI******************************sdfasd34jmkl3j4",
"expires_in": 36000,
"refresh_expires_in": 1800,
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5c***********************************T_PBkAaGat4",
"token_type": "Bearer",
"not-before-policy": 0,
"session_state": "44d7db7f-d438-4f9f-bf34-78dea43b2f78",
"scope": "openid email profile"
},
"stsToken": {
"STSAccessKeyID": "GT0****************9QHJ5",
"STSSecretAccessKey": "u0A1gjv*********************tUw4gs",
"STSSessionToken": "eyJhbGciOiJIUzUxMiIsIn*******************************************LxsLVSVd0IzzfzyqriA"
}
}
}
请求失败示例¶
// WARNING: For GET requests, body is set to null by browsers.
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("GET", "http://vod.test.mediacloud.imgo.tv/api/v1/medias/9f64e048-cac8-479f-9171-87c281f09755");
xhr.setRequestHeader("Authorization", "Bearer eyJhbGciOiJ******************************************************************************rwfH6IEJT8Nqn-CtWEDwbBEMuXDg");
xhr.send();
返回结果¶
点播服务 API 默认返回 JSON 数据,以下是返回结果示例:
{
"requestId": "423901a6-c6db-4350-99e3-9e6a0466f778",
"code": 404,
"msg": "record not found",
"status": "error",
"data": null
}
注意:目前只要请求被服务端正常处理了,响应的 HTTP 状态码均为200。例如返回的消息体里的错误码是 404,但 HTTP 状态码是200,而不是404。