Lychee.WeChat.Applet 1.0.3

dotnet add package Lychee.WeChat.Applet --version 1.0.3
NuGet\Install-Package Lychee.WeChat.Applet -Version 1.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lychee.WeChat.Applet" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Lychee.WeChat.Applet --version 1.0.3
#r "nuget: Lychee.WeChat.Applet, 1.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Lychee.WeChat.Applet as a Cake Addin
#addin nuget:?package=Lychee.WeChat.Applet&version=1.0.3

// Install Lychee.WeChat.Applet as a Cake Tool
#tool nuget:?package=Lychee.WeChat.Applet&version=1.0.3

一、说明

因为不太喜欢现有部分微信 SDK 接口设计,但自己平时工作又常用到,所以以自己喜欢的方式实现了一套微信小程序的服务器端 SDK

AccessToken 默认使用自带的内存缓存实现,如需分布式缓存或其他缓存,请自行实现接口 ICachingProvider。使用 builder.Service.AddWeChatCacheProvider<CustomCachingProvider> 注册。

二、使用方式

// 注册服务
builder.Services.AddWeChatApplet(options => 
{
	options.AccessTokenExpiresIn = 7200;
	options.Accounts.AddAccount("AppId","AppSecret","Name");
});

// 添加自定义 AccessToken 缓存
builder.Service.AddWeChatCacheProvider<CustomCachingProvider>();

public class DemoService
{
	private readonly AppletClient client
	
	public DemoService(AppletClient client)
	{
		this.client = client;
	}

	public void Code2SessionAsync()
	{
		// 方式一(如果只添加了一个小程序账号,则推荐使用此方式)
		await this.client.Auth.Code2SessionAsync("code");

		// 方式二(如果系统管理多个小程序账号,推荐使用该方式,With 方法的参数 Name 为添加小程序账号时自定义的名称,如果添加小程序时未定义 Name, 则默认使用小程序 AppId)
		await this.client.With("Name").Auth.Code2SessionAsync("code");
	}
}

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 345 11/9/2022
1.0.2 313 11/8/2022
1.0.1 307 11/8/2022
1.0.0 320 11/6/2022
0.0.2 290 12/16/2021
0.0.1 258 12/16/2021