Skip to content

Commit

Permalink
docs: 完善文档
Browse files Browse the repository at this point in the history
  • Loading branch information
fudiwei committed Mar 9, 2024
1 parent 9b7fe13 commit 2d65f8b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 14 deletions.
13 changes: 13 additions & 0 deletions docs/DouyinOpen/Advanced_Dispose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## 如何销毁客户端?

---

本功能来自于公共组件,请参阅公共组件下的相关文档:

> [《SKIT.FlurlHttpClient FAQ:如何销毁客户端(避免内存泄漏)?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/README.md)
---

### 镜像站点

国内用户如访问 GitHub 网络状况不佳,可在打开上述链接后,手动将域名部分的 **github.com** 替换为 **gitee.com**、剩余路径部分保持不变,即可访问。
4 changes: 2 additions & 2 deletions docs/DouyinOpen/Advanced_IHttpClientFactory.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## 如何在 ASP.NET Core 中与 `IHttpClientFactory` 集成?
## 如何与 `IHttpClientFactory` 集成?

---

本功能来自于公共组件,请参阅公共组件下的相关文档:

> [《SKIT.FlurlHttpClient FAQ:如何在 ASP.NET Core 中与 IHttpClientFactory 集成?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/FAQ_IHttpClientFactory.md)
> [《SKIT.FlurlHttpClient FAQ:如何与 IHttpClientFactory 集成?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/README.md)
---

Expand Down
2 changes: 1 addition & 1 deletion docs/DouyinOpen/Advanced_Interceptor.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

本功能来自于公共组件,请参阅公共组件下的相关文档:

> [《SKIT.FlurlHttpClient FAQ:如何使用拦截器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/FAQ_Interceptor.md)
> [《SKIT.FlurlHttpClient FAQ:如何使用拦截器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/README.md)
---

Expand Down
2 changes: 1 addition & 1 deletion docs/DouyinOpen/Advanced_JsonSerializer.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

本功能来自于公共组件,请参阅公共组件下的相关文档:

> [《SKIT.FlurlHttpClient FAQ:如何指定 JSON 序列化器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/FAQ_JsonSerializer.md)
> [《SKIT.FlurlHttpClient FAQ:如何指定 JSON 序列化器?》](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient/blob/main/docs/README.md)
---

Expand Down
8 changes: 4 additions & 4 deletions docs/DouyinOpen/Basic_EventDeserialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

```csharp
/* 以 authorize 事件为例 */
string callbackJson = "{ ... }";
var callbackModel = client.DeserializeEvent<Events.AuthorizeEvent>(callbackJson);
string webhookJson = "{ ... }";
var webhookModel = client.DeserializeEvent<Events.AuthorizeEvent>(webhookJson);
```

完整的 Webhook 模型定义可以参考项目目录下的 _src/SKIT.FlurlHttpClient.ByteDance.DouyinOpen/Events_ 目录。
Expand All @@ -21,14 +21,14 @@ var callbackModel = client.DeserializeEvent<Events.AuthorizeEvent>(callbackJson)
这里给出一种解决方案:

```csharp
DouyinOpenEvent eventModel = client.DeserializeEvent(callbackJson);
DouyinOpenEvent eventModel = client.DeserializeEvent(webhookJson);
string eventType = eventModel.Event?.ToLower();

switch (eventType)
{
case "authorize":
{
var callbackModel = client.DeserializeEvent<Events.AuthorizeEvent>(callbackJson);
var webhookModel = client.DeserializeEvent<Events.AuthorizeEvent>(webhookJson);
}
break;
// 省略其他情况
Expand Down
4 changes: 2 additions & 2 deletions docs/DouyinOpen/Basic_EventSignatureVerification.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
```csharp
/* 验证 Webhook 事件签名 */
bool ret = client.VerifyEventSignature(
callbackJson: "抖音 Webhook 事件中请求正文",
callbackSignature: "抖音 Webhook 事件中的 X-Douyin-Signature 字段"
webhookJson: "抖音 Webhook 事件中请求正文",
webhookSignature: "抖音 Webhook 事件中的 X-Douyin-Signature 字段"
);
```
11 changes: 7 additions & 4 deletions docs/DouyinOpen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- 基于抖音开放平台 API 封装。
- 提供了抖音开放平台 API 所需的 AES、MD5、SHA-1、SHA-256、HMAC-SHA-256 等算法工具类。
- 提供了生成授权链接、生成 JSBridge 签名、解析回调通知事件、解密手机号码等扩展方法。
- 配合 [SKIT.FlurlHttpClient.ByteDance.MicroApp](../MicroApp/README.md) 模块,可无缝对接抖音小程序开放平台。

---

Expand Down Expand Up @@ -36,7 +37,7 @@ var options = new DouyinOpenClientOptions()
ClientKey = "抖音开放平台应用 Key",
ClientSecret = "抖音开放平台应用密钥"
};
var client = new DouyinOpenClient(options);
var client = DouyinOpenClientBuilder.Create(options).Build();
```

### 请求 & 响应:
Expand Down Expand Up @@ -68,13 +69,13 @@ else

## 基础用法

- [如何快速找到需要调用的 API 模型类名 / 方法名?](./Basic_ModelDefinition.md)
- [如何快速找到需要调用的 API 模型类名 / 方法名?](./Basic_ModelDefinition.md)

- [如何解析 Webhook 事件?](./Basic_EventDeserialization.md)

- [如何验证 Webhook 事件签名?](./Basic_EventSignatureVerification.md)

- [如何生成 JSBridge 初始化时所需的参数及签名?](./Basic_Parameters.md)
- [如何生成 JSBridge 初始化时所需的参数及签名?](./Basic_Parameters.md)

- [如何解密用户公开信息中的手机号码?](./Basic_MobileNumberDecryption.md)

Expand All @@ -86,7 +87,9 @@ else

## 高级技巧

- [如何在 ASP.NET Core 中与 `IHttpClientFactory` 集成?](./Advanced_IHttpClientFactory.md)
- [如何销毁客户端?](./Advanced_Dispose.md)

- [如何与 `IHttpClientFactory` 集成?](./Advanced_IHttpClientFactory.md)

- [如何指定 JSON 序列化器?](./Advanced_JsonSerializer.md)

Expand Down

0 comments on commit 2d65f8b

Please sign in to comment.