Myvas.AspNetCore.Weixin
9.0.0-preview.14
See the version list below for details.
dotnet add package Myvas.AspNetCore.Weixin --version 9.0.0-preview.14
NuGet\Install-Package Myvas.AspNetCore.Weixin -Version 9.0.0-preview.14
<PackageReference Include="Myvas.AspNetCore.Weixin" Version="9.0.0-preview.14" />
<PackageVersion Include="Myvas.AspNetCore.Weixin" Version="9.0.0-preview.14" />
<PackageReference Include="Myvas.AspNetCore.Weixin" />
paket add Myvas.AspNetCore.Weixin --version 9.0.0-preview.14
#r "nuget: Myvas.AspNetCore.Weixin, 9.0.0-preview.14"
#addin nuget:?package=Myvas.AspNetCore.Weixin&version=9.0.0-preview.14&prerelease
#tool nuget:?package=Myvas.AspNetCore.Weixin&version=9.0.0-preview.14&prerelease
Myvas.AspNetCore.Weixin
WeixinApi services and WeixinSite middleware for Tencent Wechat/Weixin messages, events and apis. (微信公众平台/接口调用服务)
微信公众平台/接口调用服务:在微信公众平台上申请服务号或订阅号后,经配置部署可提供自定义菜单、即时信息交流、微信网页授权、模板消息通知等接口调用及搭建站点。NuGet Packages
获取配置参数 Options
微信公众平台:https://mp.weixin.qq.com
开发/基本配置/公众号开发信息
- 获取AppId,作为参数
<WeixinOptions>.AppId
- 获取AppSecret,作为参数
<WeixinOptions>.AppSecret
- 获取AppId,作为参数
开发/基本配置/服务器配置:修改设置 | 启用
- 在“服务器地址(URL)”中,填写地址: http://xxx.xxx/wx or https://xxx.xxx/wx,将二级虚拟路径(`"/wx"`)作为参数`<WeixinSiteOptions>.Path`
- 在“网站Token”中,填写一串较长的随机字符串,作为参数
<WeixinSiteOptions>.WebsiteToken
- 在“消息加解密密钥EncodingAESKey”中,若空则初始化一个,作为参数
<WeixinMessageProtectionOptions>.EncodingAESKey
- 在“消息加解密方式”中,建议选择“安全模式”。其他选项有"明文模式"和"兼容模式"。当且仅当您选择"安全模式"时,将参数
<WeixinMessageProtectionOptions>.StrictMode
设置为true
。
微信接口服务容器 WeixinBuilder
// Optional: AddWeixinCore(...) for IWeixinAccessTokenApi and WeixinMemoryCacheProvider only.
services.AddWeixin(o => {
o.AppId = Configuration["Weixin:AppId"];
o.AppSecret = Configuration["Weixin:AppSecret"];
//o.Backchannel = _testServer.CreateClient(); // For testing on your FakeServer
})
// WeixinMemoryCacheProvider has already injected as the default.
// WeixinRedisCacheProvider is also a better choice for distribution cache.
// or replace by your customized implementation of IWeixinCacheProvider.
//.AddWeixinCacheProvider<YourCacheProvider>()
;
- 微信接口服务注入
<IServiceCollection>.AddWeixin(Action<WeixinOptions>)
: 注入所有接口<IServiceCollection>.AddWeixinCore(Action<WeixinOptions>)
: 注入基础会话接口
- 基础会话接口:
- 数据管理接口:
IWeixinUserApi
:IWeixinUserProfileApi
:IWeixinUserGroupApi
:IWeixinGroupApi
:
- 其他业务接口:
IWeixinCommonApi
:IWeixinMenuApi
:IWeixinMediaApi
:IWeixinCustomerSupportApi
:IWeixinGroupMessageApi
:IWeixinQrcodeApi
:IWeixinWifiApi
:
- Generic Cache Providers for
TWeixinCacheJson
:IWeixinCacheJson
WeixinMemoryCacheProvider<TWeixinCacheJson>
(Default injected inAddWeixin(...)
andAddWeixinCore(...)
)<WeixinBuilder>.AddWeixinMemoryCacheProvider<TWeixinCacheJson>()
WeixinRedisCacheProvider<TWeixinCacheJson>
<WeixinBuilder>.AddWeixinRedisCacheProvider<TWeixinCacheJson>(Action<RedisCacheOptions>)
- Customized Interface type:
IWeixinCacheProvider<TWeixinCacheJson>
- XxxCacheProviderOptions:
TOptions
- XxxCacheProviderPostConfigureOptions:
IPostConfigureOptions<TOptions>
- WeixinBuilderXxxCacheProviderExtensions:
<WeixinBuilder>.AddWeixinCacheProvider<TWeixinCacheJson, TWeixinCacheProvider>(Action<TWeixinCacheProviderOptions> setupAction = null)
- XxxCacheProviderOptions:
微信公众号服务站点-中间件 WeixinSiteMiddleware
Use Middleware:
<IApplicationBuilder>.UseMiddleware<WeixinSiteMiddleware>
app.UseWeixinSite();
用于搭建微信公众号服务站点
- 接收微信公众号上行的消息和事件: Usage
- 发送(客服)响应类消息(须有上行消息,并在48小时内回复)
- 发送模板消息(须预先定义并申请消息模板),模板存储及管理
微信公众号服务站点-接口服务容器 WeixinSiteBuilder
Dependency Injection:
IServiceCollection
// <WeixinBuilder> .AddWeixinSite(o => { o.Path = Configuration["Weixin:Path"]; o.WebsiteToken = Configuration["Weixin:WebsiteToken"]; o.Debug = false; //默认为false,即:不允许微信web开发者工具(wechatdevtools)等客户端访问。若修改为true则允许。 }) // 上下行消息加解密 .AddWeixinMessageProtection(o => { o.StrictMode = true; // default is false (compatible with ClearText) o.EncodingAESKey = Configuration["Weixin:EncodingAESKey"];//请注意检查该值正确无误! // (1)若填写错误,将导致您在启用“兼容模式”或“安全模式”时无法正确解密(及加密); // (2)若您使用“微信公众平台测试号”部署,您应当注意到其不支持消息加解密,此时须用空字符串或不配置。 }); // 上行消息及事件通知,已默认注入`WeixinEventSink` //.AddWeixinEventSink<TWeixinEventSink>() // 接口服务:发送模板消息 .AddWeixinTemplateMessaging(o => { o.MaxRetryTimes = 5; // default is 3 }) // 接口服务:发送客服响应消息 .AddWeixinPassiveResponseMessaging(o => { o.TrySmsOnFailed = true; // default is false }) // 自动存储上行消息及事件 .AddWeixinEntityFrameworkCore(o => { // 启用订阅者名单同步服务 o.EnableSubscriberSync = false; // default is true }) // 自定义数据类型 //.AddWeixinEntityFrameworkCore<TWeixinSubscriber, TWeixinDbContext>(Action<TWeixinEntityFrameworkCoreOptions>);
Demo
http://demo.auth.myvas.com (debian.9-x64)
For Developers
- Visual Studio 2022
- Visual Studio Code
- C#, IntelliCode, .NET Install Tool (Microsoft)
- XML Tools (Josh Johnson)
- .NET Core User Secrets (Adrian Wilczyński)
- ResX Editor (Dominic Vonk)
- Markdown All in One (Yu Zhang)
- Testing on:
- 微信开发者工具
- 微信公众平台
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. net9.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
- Microsoft.EntityFrameworkCore.Relational (>= 3.1.4)
- Microsoft.Extensions.Caching.Memory (>= 3.1.4)
- Microsoft.Extensions.Http (>= 3.1.4)
- Microsoft.Extensions.Logging (>= 3.1.4)
- Microsoft.Extensions.Options (>= 3.1.4)
- Microsoft.Extensions.Options.DataAnnotations (>= 3.1.4)
- System.ComponentModel.Annotations (>= 4.7.0)
- System.Net.Http.Json (>= 3.2.0)
- System.Security.Cryptography.Algorithms (>= 4.3.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Myvas.AspNetCore.Weixin:
Package | Downloads |
---|---|
Myvas.AspNetCore.Weixin.Jssdk
Myvas.AspNetCore.Weixin.Jssdk |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
9.0.0 | 137 | 3/31/2025 | |
9.0.0-rc.7 | 53 | 3/29/2025 | |
9.0.0-rc.6 | 475 | 3/25/2025 | |
9.0.0-rc.5 | 483 | 3/25/2025 | |
9.0.0-rc.3 | 178 | 3/23/2025 | |
9.0.0-rc.1 | 200 | 3/19/2025 | |
9.0.0-preview.25 | 126 | 3/22/2025 | |
9.0.0-preview.24 | 189 | 3/21/2025 | |
9.0.0-preview.23 | 199 | 3/18/2025 | |
9.0.0-preview.22 | 194 | 3/18/2025 | |
9.0.0-preview.21 | 198 | 3/17/2025 | |
9.0.0-preview.18 | 213 | 3/17/2025 | |
9.0.0-preview.17 | 192 | 3/17/2025 | |
9.0.0-preview.14 | 118 | 3/15/2025 | |
9.0.0-preview.13 | 164 | 3/14/2025 | |
9.0.0-preview.12 | 196 | 3/13/2025 | |
9.0.0-preview.11 | 202 | 3/12/2025 | |
9.0.0-preview.10 | 200 | 3/12/2025 | |
9.0.0-preview.9 | 208 | 3/10/2025 | |
9.0.0-preview.8 | 203 | 3/9/2025 | |
9.0.0-preview.7 | 179 | 3/9/2025 | |
9.0.0-preview.6 | 250 | 3/6/2025 | |
9.0.0-preview.5 | 253 | 3/5/2025 | |
3.1.100.8 | 986 | 12/14/2019 | |
3.1.100.5 | 742 | 12/13/2019 | |
2.2.403 | 708 | 11/1/2019 |