Skip to content

Latest commit

 

History

History
107 lines (71 loc) · 3.01 KB

File metadata and controls

107 lines (71 loc) · 3.01 KB

SKIT.FlurlHttpClient.ByteDance.DouyinOpen

基于 Flurl.Http抖音开放平台 HTTP API SDK。


功能

  • 基于抖音开放平台 API 封装。
  • 提供了抖音开放平台 API 所需的 AES、MD5、SHA-1、SHA-256、HMAC-SHA-256 等算法工具类。
  • 提供了生成授权链接、生成 JSBridge 签名、解析回调通知事件、解密手机号码等扩展方法。
  • 配合 SKIT.FlurlHttpClient.ByteDance.MicroApp 模块,可无缝对接抖音小程序开放平台。

快速入门

Important

此目录下的文档适用于 v3.x 版本的模块。如果你正在使用 2.x 版本,请移步至 GitHub/Gitee 的已归档分支。

安装:

提示:如果你使用 Visual Studio NuGet 管理器图形化界面,请在搜索结果中勾选“包括预发行版”。

# 通过 NuGet 安装
> Install-Package SKIT.FlurlHttpClient.ByteDance.DouyinOpen

# 通过 dotnet-tools 安装
> dotnet add package SKIT.FlurlHttpClient.ByteDance.DouyinOpen

初始化:

using SKIT.FlurlHttpClient.ByteDance.DouyinOpen;

var options = new DouyinOpenClientOptions()
{
    ClientKey = "抖音开放平台应用 Key",
    ClientSecret = "抖音开放平台应用密钥"
};
var client = DouyinOpenClientBuilder.Create(options).Build();

请求 & 响应:

using SKIT.FlurlHttpClient.ByteDance.DouyinOpen;
using SKIT.FlurlHttpClient.ByteDance.DouyinOpen.Models;

/* 以获取用户信息接口为例 */
var request = new OAuthUserInfoRequest()
{
    AccessToken = "抖音开放平台的 AccessToken",
    OpenId = "用户唯一标识"
};
var response = await client.ExecuteOAuthUserInfoAsync(request);
if (response.IsSuccessful())
{
    Console.WriteLine("昵称:" + response.Data.Nickname);
    Console.WriteLine("头像:" + response.Data.AvatarUrl);
}
else
{
    Console.WriteLine("错误代码:" + response.Extra?.ErrorCode);
    Console.WriteLine("错误描述:" + response.Extra?.ErrorDescription);
}

基础用法


高级技巧


迁移指南