Secondary authentication C #,
Using Senparc. weixin. entities; using Senparc. weixin. httpUtility; using Senparc. weixin. QY. advancedAPIs. oau22. using Senparc. weixin. QY. commonAPIs; using System. collections. generic; using System. linq; using System. web; using System. web. UI; using System. web. UI. webControls; namespace CRM. CIS. weiXin {public partial class TwoVerification: System. web. UI. page {protected void Page_Load (object sender, EventArgs e) {if (! IsPostBack) {string code = Request ["code"]; string state = Request ["state"]; if (! String. IsNullOrEmpty (code )&&! String. IsNullOrEmpty (state) {string CorpId = Properties. Settings. Default. CorpId; string Secret = Properties. Settings. Default. Secret;
// Register corpid if (! AccessTokenContainer. checkRegistered (CorpId) {AccessTokenContainer. register (CorpId, Secret);} string accessToken = AccessTokenContainer. getToken (CorpId); GetUserIdResult guir = Senparc. weixin. QY. advancedAPIs. OAuth2.OAuth2Api. getUserId (accessToken, code, 1); if (guir. errcode = 0 ){
// Read employee status var member = Senparc. weixin. QY. advancedAPIs. mailList. mailListApi. getMember (accessToken, guir. userId); hfaccessToken. value = accessToken; // uses HiddenField to save the hfValue. value = guir. userId; // The uid objectperformance1.databind (); if (member. status = 1) {btnOK. enabled = false; btnOK. text = "followed";} else if (member. status = 2) {btnOK. enabled = false; btnOK. text = "Frozen";} else {btnOK. enabled = true; btnOK. text = "Please note" ;}}# if DEBUG else {hfValue. value = "MysticBoy"; objectperformance1.databind () ;}# endif }}
// This is a method to query the content displayed in objectperformance1 from the database. Write this code as needed: public bas_Company GetCompanyInfo (string userid) {bas_Company result = null; using (CISDBEntities ef = new CISDBEntities () {var ci = from c in ef. bas_Company where c. userName = userid select c; if (ci. any () {result = ci. single () ;}} return result;} protected void btnOK_Click (object sender, EventArgs e) {string userId = hfValue. value; string accessToken = hfaccessToken. value; var member = Senparc. weixin. QY. advancedAPIs. mailList. mailListApi. getMember (accessToken, userId );
// Based on the last retained accessToken userId, check whether the member has been noticed, especially after the member is clicked in the mobile phone! If (member. status = 4) // Yes not followed {
// Inside the https://github.com/JeffreySu/WeiXinMPSDK
// Senparc. Weixin. QY. AdvancedAPIs. Concern. ConcernApi. TwoVerification
// As of April 14, 2015, the following parameters were not passed, so use your own code var url = string. Format ("https://qyapi.weixin.qq.com/cgi-bin/user/authsucc? Access_token = {0} & userid = {1} ", accessToken, userId); var result = Get. getJson <QyJsonResult> (url); if (result. errcode = 0) {btnOK. enabled = false; btnOK. text = "followed";} else {btnOK. text = result. errmsg;} else if (member. status = 1) // you have followed {btnOK. enabled = false; btnOK. text = "followed";} else if (member. status = 2) // frozen {btnOK. enabled = false; btnOK. text = "Frozen ";}}}}
Because my job is to use C for Embedded Application Development in Linux, the BS is inferior to others.