列出并筛选播放列表
学习并实践如何使用 Dailymotion Data API 检索播放列表以及筛选播放列表属性。
// 在此处定义 API 密钥 const API_KEY = 'Bearer {{ACCESS_TOKEN}}';
// 在此处定义接口地址 const endpointUrl = 'https://api.dailymotion.com/playlists';
// 在此处定义请求头参数 const headerParameters = { authorization: API_KEY, "Content-Type": "application/json", };
// 设置 API 请求选项 const options = { method: "GET", headers: headerParameters, };
// 用于发起 API 请求的函数
async function fetchVideosList() {
try {
const response = await fetch(${endpointUrl}, options);
1// 输出响应结果 2printResponse(response);
} catch (error) { // 输出错误信息 printError(response); } }
// 调用函数以发起 API 请求 fetchVideosList();
| 字段 | 类型 | 分类 | 描述 |
|---|---|---|---|
| created_time | 日期 | 可选 | 该播放列表的创建时间。 |
| description | 字符串 | 可选 | 该播放列表的描述信息。 |
| id | 字符串 | 可选 | 播放列表的唯一标识 ID。 |
| name | 字符串 | 可选 | 播放列表的名称。 |
| owner | 用户 | 可选 | 播放列表的所有者。 |
| private | 布尔值 | 可选 | 若播放列表为私有,则值为 true,否则为 false。 |
| updated_time | 日期 | 可选 | 播放列表最后一次更新的时间。 |
| videos_total | 整数 | 可选 | 播放列表中视频的总数。 |
// 在此处定义 API 密钥 const API_KEY = 'Bearer {{ACCESS_TOKEN}}';
// 在此处定义接口地址 const endpointUrl = 'https://api.dailymotion.com/playlist/{{PLAYLIST_ID}}';
// 在此处定义请求头参数 const headerParameters = { authorization: API_KEY, "Content-Type": "application/json", };
// 在此处定义查询参数 const queryParameters = new URLSearchParams({ fields: "owner,videos_total" });
// 设置 API 请求选项 const options = { method: "GET", headers: headerParameters, };
// 用于发起 API 请求的函数
async function fetchSpecificVideo() {
try {
const response = await fetch(${endpointUrl}?${queryParameters.toString()}, options);
1// 输出响应结果 2printResponse(response);
} catch (error) { // 输出错误信息 printError(response); } }
// 调用函数以发起 API 请求 fetchSpecificVideo();