Skip to content

Commit

Permalink
feat(tiktok): 新增查询播放列表统计数据接口
Browse files Browse the repository at this point in the history
  • Loading branch information
fudiwei committed Aug 8, 2024
1 parent de0e586 commit 16728bf
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/TikTokGlobal/Basic_ModelDefinition.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Naming Policies:
- Query User Followers: `ResearchUserFollowers`
- Query User Following: `ResearchUserFollowing`
- Query User Reposted Videos: `ResearchUserRepostedVideos`
- Query Playlists: `ResearchPlaylistInfo`
- Commercial Content
- Query Ads: `ResearchAdlibAdQuery`
- Query Advertisers: `ResearchAdlibAdvertiserQuery`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,30 @@ public static class TikTokV2ClientExecuteResearchExtensions
}
#endregion

#region Playlist
/// <summary>
/// <para>异步调用 [POST] /research/playlist/info/ 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developers.tiktok.com/doc/research-api-specs-query-playlist-info ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ResearchPlaylistInfoResponse> ExecuteResearchPlaylistInfoAsync(this TikTokV2Client client, Models.ResearchPlaylistInfoRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));

IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Post, "research", "playlist", "info/");

return await client.SendFlurlRequestAsJsonAsync<Models.ResearchPlaylistInfoResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
#endregion

#region User
/// <summary>
/// <para>异步调用 [POST] /research/user/info/ 接口。</para>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobal.Models
{
/// <summary>
/// <para>表示 [POST] /research/playlist/info/ 接口的请求。</para>
/// </summary>
public class ResearchPlaylistInfoRequest : TikTokV2Request
{
/// <summary>
/// 获取或设置播放列表 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("playlist_id")]
[System.Text.Json.Serialization.JsonPropertyName("playlist_id")]
public long PlaylistId { get; set; }

/// <summary>
/// 获取或设置分页游标。
/// </summary>
[Newtonsoft.Json.JsonProperty("cursor")]
[System.Text.Json.Serialization.JsonPropertyName("cursor")]
public long? PageCursor { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace SKIT.FlurlHttpClient.ByteDance.TikTokGlobal.Models
{
/// <summary>
/// <para>表示 [POST] /research/playlist/info/ 接口的响应。</para>
/// </summary>
public class ResearchPlaylistInfoResponse : TikTokV2Response<ResearchPlaylistInfoResponse.Types.Data>
{
public static class Types
{
public class Data
{
/// <summary>
/// 获取或设置播放列表 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("playlist_id")]
[System.Text.Json.Serialization.JsonPropertyName("playlist_id")]
public long PlaylistId { get; set; }

/// <summary>
/// 获取或设置播放列表名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("playlist_name")]
[System.Text.Json.Serialization.JsonPropertyName("playlist_name")]
public string PlaylistName { get; set; } = default!;

/// <summary>
/// 获取或设置视频总数。
/// </summary>
[Newtonsoft.Json.JsonProperty("playlist_item_total")]
[System.Text.Json.Serialization.JsonPropertyName("playlist_item_total")]
public int TotalItemCount { get; set; }

/// <summary>
/// 获取或设置最后更新时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("playlist_last_updated")]
[System.Text.Json.Serialization.JsonPropertyName("playlist_last_updated")]
public long UpdateTimestamp { get; set; }

/// <summary>
/// 获取或设置视频 ID 列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("playlist_video_ids")]
[System.Text.Json.Serialization.JsonPropertyName("playlist_video_ids")]
public long[]? VideoIdList { get; set; }
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"playlist_id": 1234534763387255595
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"data": {
"playlist_id": 1234579763387255595,
"playlist_item_total": 4,
"playlist_last_updated": 1663620215,
"playlist_name": "Test playlist name",
"playlist_video_ids": [
12351810646859,
7289561123404511,
7274412345315375,
12312311231231231,
12312883434352176,
71919242345289237,
7190923438988788,
71800659413240905
]
},
"error": {
"code": "ok",
"message": "ok",
"log_id": "20240700200656033B747EC0C8DE33C94C"
}
}

0 comments on commit 16728bf

Please sign in to comment.