MinimalApi.Extensions.WeChat
1.0.0-beta
This is a prerelease version of MinimalApi.Extensions.WeChat.
dotnet add package MinimalApi.Extensions.WeChat --version 1.0.0-beta
NuGet\Install-Package MinimalApi.Extensions.WeChat -Version 1.0.0-beta
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="MinimalApi.Extensions.WeChat" Version="1.0.0-beta" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MinimalApi.Extensions.WeChat" Version="1.0.0-beta" />
<PackageReference Include="MinimalApi.Extensions.WeChat" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MinimalApi.Extensions.WeChat --version 1.0.0-beta
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MinimalApi.Extensions.WeChat, 1.0.0-beta"
#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.
#:package MinimalApi.Extensions.WeChat@1.0.0-beta
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MinimalApi.Extensions.WeChat&version=1.0.0-beta&prerelease
#tool nuget:?package=MinimalApi.Extensions.WeChat&version=1.0.0-beta&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MinimalApi.Extensions.WeChat
微信 网站应用
openapi
准备
微信开放平台注册开发者账号,并拥有一个已审核通过的网站应用,并获得相应的AppID和AppSecret
安装
dotnet add package MinimalApi.Extensions.WeChat
配置
两种配置方式:
- 代码中填写
using MinimalApi.Extensions.WeChat;
services.AddWeChatService(o=>
{
o.AppId = "xxx";
o.AppSecret = "xxxxx";
});
- 配置文件中配置(提供IConfiguration)
{
"WeChat":{
"AppId" : "xxx",
"AppSecret" : "xxxxxx"
}
}
services.AddWeChatService(configuration.GetSection("WeChat"));
使用
app.MapGet("login",async ([FromService] WeChatService weChatService, string code)=>{
var response = await weChatService.GetAccessTokenAsync(code);
return Results.Ok(response);
});
api 列表
方法名 | 作用 |
---|---|
GetAccessTokenAsync | 通过code获取网站授权 access_token |
RefreshAccessTokenAsync | 刷新或续期网站授权 access_token 使用 |
GetUserInfoAsync | 获取用户信息 |
说明
- 支持
aot
编译 - 注册了名字为
wx_http_client
的HttpClient
, 请不要覆盖注册, 通过httpClientFactory.CreateClient(WeChatOptions.HTTP_CLIENT_NAME)
获取HttpClient
实例 - 可以通过注入
IOptions<WeChatOptions>
获取配置 - 为了性能考虑,
WeChatService
被注册为单例
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MinimalApi.Extensions.WeChat:
Package | Downloads |
---|---|
MinimalApi.Extensions
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0-beta | 185 | 4/20/2025 |