Senparc.Weixin.MP SDK? ?? WeChat 6.x? ?? ?? API? ??? ????.
?? ????? ?? ??? ???? ????? ? ?????? ?? ? ????: https://github.com/JeffreySu/WeiXinMPSDK
PS: WeChat API ? Senparc? ??. Weixin SDK? ????? ????? ? ?????????. ?? ??? ???? ? github? ?? ??? ?????.
?? WeChat? ???? ??? ???? ?? ???? ASP.NET MVC ????? ???? ????(? ??? ??? ?????. ????? ??? .aspx ???? ??? ???).
??? ????? ????? ???? ??????? ??? ? ????. (????? 2?? ????? 1?? ??? ????? ???? ?? ??? ?? ??? ?? ??? ?? ????. , ??? ??? ??? ?????):
MVC: https://github.com/JeffreySu/WeiXinMPSDK/tree/master/Senparc.Weixin.MP.Sample
WebForms: https: //github.com/JeffreySu/WeiXinMPSDK /tree/master/Senparc.Weixin.MP.Sample.WebForms
1??: ? ASP.NET ??? MVC(4.0) ????, Senparc.Weixin.MP.Sample? ?? ???? ??
2??: WeixinController.cs? ?? ???? ??
3??: Senparc.Weixin.MP.dll ??
?? dll? ???? ???? ? ??? ????. ??? dll? ????? ?? ??? ??? ?? ????? Senparc.Weixin.MP.dll ? Senparc.Weixin.MP.MvcExtension.dll? ?? ??? ?? ?????(Senparc.Weixin.MP.MvcExtension.dll? ???) MVC ????? ?? WebForms ????? ?? ??? ? ??), ? ?? ??? ?? Nuget? ???? ????? ?? ??? ? ????.
Nuget ???? ??: https://www.nuget.org/packages/Senparc.Weixin.MP/
? ?? ??? ?? ???? ? ?? ??? ??? ????. ??? ?? [??]> [????? ??? ???] > [??? ??? ??] ??? ???.
???? ??? ??? ??? ?????. :
Senparc.Weixin.MP ?????? ?? ???? ?? PM> ?? ?? ??? ?????.
Install- Package Senparc.Weixin.MP
Enter ?? ??? Senparc.Weixin.MP.dll? ???? ????? ?????.
??? ?? ???? ?????? ?? ?? ???? ????? ?????? Update-Package ??? ?????.
Update-Package Senparc.Weixin.MP
? ??? MVC ? WebForms ???? ??? ?????.
MVC ????? ?? MVC? ?? ? ?? ?? ??? ?? ?? Senparc.Weixin.MP.MvcExtension.dll? ?? ??? ? ????.
Install-Package Senparc.Weixin .MP.MVC
?? ? ??? ??? ??? ??? ????? ?????.
???? ?? ????? ???????. ?? ? dll? ???????.
4??: WeixinController.cs ??
us WeixinController.cs? ?? ??? ?????:
using System; using System.IO; using System.Web.Configuration; using System.Web.Mvc; using Senparc.Weixin.MP.Entities.Request; namespace Senparc.Weixin.MP.Sample.Controllers { using Senparc.Weixin.MP.MvcExtension; using Senparc.Weixin.MP.Sample.CommonService.CustomMessageHandler; public partial class WeixinController : Controller { public static readonly string Token = "YourToken";//與微信公眾賬號(hào)后臺(tái)的Token設(shè)置保持一致,區(qū)分大小寫。 public static readonly string EncodingAESKey = "YourKey";//與微信公眾賬號(hào)后臺(tái)的EncodingAESKey設(shè)置保持一致,區(qū)分大小寫。 public static readonly string AppId = "YourAppId";//與微信公眾賬號(hào)后臺(tái)的AppId設(shè)置保持一致,區(qū)分大小寫。 /// <summary> /// 微信后臺(tái)驗(yàn)證地址(使用Get),微信后臺(tái)的“接口配置信息”的Url填寫如:http://weixin.senparc.com/weixin /// </summary> [HttpGet] [ActionName("Index")] public ActionResult Get(PostModel postModel, string echostr) { if (CheckSignature.Check(postModel.Signature, postModel.Timestamp, postModel.Nonce, Token)) { return Content(echostr); //返回隨機(jī)字符串則表示驗(yàn)證通過 } else { return Content("failed:" + postModel.Signature + "," + MP.CheckSignature.GetSignature(postModel.Timestamp, postModel.Nonce, Token) + "。" + "如果你在瀏覽器中看到這句話,說明此地址可以被作為微信公眾賬號(hào)后臺(tái)的Url,請(qǐng)注意保持Token一致。"); } } /// <summary> /// 用戶發(fā)送消息后,微信平臺(tái)自動(dòng)Post一個(gè)請(qǐng)求到這里,并等待響應(yīng)XML。 /// PS:此方法為簡化方法,效果與OldPost一致。 /// v0.8之后的版本可以結(jié)合Senparc.Weixin.MP.MvcExtension擴(kuò)展包,使用WeixinResult,見MiniPost方法。 /// </summary> [HttpPost] [ActionName("Index")] public ActionResult Post(PostModel postModel) { if (!CheckSignature.Check(postModel.Signature, postModel.Timestamp, postModel.Nonce, Token)) { return Content("參數(shù)錯(cuò)誤!"); } postModel.Token = Token;//根據(jù)自己后臺(tái)的設(shè)置保持一致 postModel.EncodingAESKey = EncodingAESKey;//根據(jù)自己后臺(tái)的設(shè)置保持一致 postModel.AppId = AppId;//根據(jù)自己后臺(tái)的設(shè)置保持一致 //自定義MessageHandler,對(duì)微信請(qǐng)求的詳細(xì)判斷操作都在這里面。 var messageHandler = new CustomMessageHandler(Request.InputStream, postModel);//接收消息 messageHandler.Execute();//執(zhí)行微信處理過程 return new FixWeixinBugWeixinResult(messageHandler);//返回結(jié)果 } } }
? ?? Get? WeChat ??????? URL? ??? ?? ??? ???? ? ?? Post? ??? ?? ??? ???? ? ?????.
? ? CustomMessageHandler? MessageHandler? ???? ?? ????? ??? ??????. (MessageHandler? ?? ??? ??? "Senparc.Weixin.MP SDK WeChat Public Platform Development Tutorial (6): Understanding MessageHandler"? ?????. ?? ??) WeChat ??? ??? ?? ?? ?? ??? CustomMessageHandler? ???? ?????. MessageHandler? WeChat ?? ?? ??? ???? ? ??? ?? ??? ?? ???? ??? ?? ??? ????? ?? ?????.
?? ?? Senparc.Weixin.MP SDK? ????? ?????? WeChat ???? "?? ??"? ???? ?? ???? ??? ? ????.
?? ?? ? ???? Url?? http://xxx/Weixin? ???? Token?? weixin? ?????.
? ?? WeChat ?? ??? ??? ???? Senparc.Weixin.MP? ?????. SDK ?? ?? PHP ??? ????? ??????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)