Skip to content

QcCoding/Qc.WechatSdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WechatSdk

Qc.WechatSdk

Qc.WechatSdk 是一个基于 .NET Standard 2.0 构建,对微信公众号平台平台的常用接口进行了封装。

已实现接口

  • 获取AccessToken
  • 微信公众号授权登录
  • 消息模板发送
  • JSSDK

使用 WechatSdk

一.安装程序包

Nuget

  • dotnet cli
    dotnet add package Qc.WechatSdk
  • 包管理器
    Install-Package Install-Package Qc.WechatSdk

二.添加配置

如需实现自定义存储 AccessToken,动态获取应用配置,可自行实现接口 IWechatSdkHook
默认提供 DefaultWechatSdkHook,存储 AccessToken 等信息到指定目录(默认./AppData)

using WechatSdk;
public void ConfigureServices(IServiceCollection services)
{
  //...
  services.AddWechatSdk<WechatSdk.DefaultWechatSdkHook>(opt =>
  {
      opt.AppId = "Wechat AppId";
      opt.Appsecret = "Wechat Appsecret";
  });
  //...
}

三.代码中使用

在需要地方注入WechatService后即可使用

private readonly WechatService _service;
public IndexModel(WechatService service)
{
    _service = service;
}
// 获取 AccessToken
var result = _service.GetAccessToken();
// 获取jssdk 配置
var jssdkConfig=_service.GetJsSdkConfig(url)

WechatConfig 配置项

Wechat文档地址: https://developers.weixin.qq.com/doc/

示例说明

Qc.WechatSdk.Sample 为示例项目,可进行测试

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published