Third-party platform set: Authorization Event Accept URL
The URL has two main functions:
(1) The server pushes the component_verify_ticket every 10 minutes at regular intervals. Third party platform received ticket
(2) If the public number cancels the authorization of the third party platform, the server informs the third party platform via this URL.
Public StringReceiveauth () {StringMsgsignature=Getrequest ().GetParameter ("Msg_signature");StringTimestamp=Getrequest ().GetParameter ("Timestamp");StringNonce=Getrequest ().GetParameter ("Nonce"); Logger.Info"Msgsignature:" +Msgsignature+ ", timestamp:" +Timestamp+ ", Nonce:" +Nonce); try {bufferedreader BR= NewBufferedReader (NewInputStreamReader (Getrequest ().getInputStream ()));StringLine= NULL; StringBuilder SB= NewStringBuilder (); while(Line=Br.ReadLine ())!= NULL) {SB.Append (line); }StringEncstr=Sb.ToString ();//Decrypt push messages if(Encstr!= NULL) {Wxbizmsgcrypt pc= NewWxbizmsgcrypt (Constants.Wx_open_token,constants.Wx_open_encoding_aeskey,constants.WX_OPEN_APPID); Documentbuilderfactory DBF=Documentbuilderfactory.Newinstance (); Documentbuilder DB=Dbf.Newdocumentbuilder (); StringReader SR= NewStringReader (ENCSTR); InputSource is= NewInputSource (SR); Document Document=Db.Parse (IS); Element Root=Document.Getdocumentelement (); NodeList Nodelist1=Root.getElementsByTagName ("Encrypt");StringEncrypt=Nodelist1.Item0).Gettextcontent ();StringFormat= "<xml><tousername><! [cdata[touser]]></tousername><encrypt><! [cdata[%s]]></encrypt></xml> ";StringFromXml= String.Format (format, encrypt);StringResultxml=Pc.Decryptmsg (Msgsignature, Timestamp,nonce, FromXml);Map<String,String>XmlMap=Messageutil.Prasexmlstring2map (Resultxml);if(StringUtils.Isnotnull (XmlMap.Get"InfoType"))&& "Unauthorized".equals(XmlMap.Get"InfoType"))){StringAppID=XmlMap.Get"Authorizerappid"); Wxaccount Account= NewWxaccount (); Account.Setaccountappid (AppID); Account=Wxaccountservice.Getwxaccount (account);if(Account!= NULL){//Public number de-authorization, set the appropriate status flagAccount.SetStatus (0); Wxaccountservice.Updatewxaccount (account); Logger.Error"Wx_account Cancel authorization Set status = 0 appid="+AppID); } }//Deposit Component_verify_ticket into Redis database StringTicket=XmlMap.Get"Componentverifyticket");if(StringUtils.Isnotnull (Ticket)) {Constants.Wx_open_component_verify_ticket=Ticket Logger.Info"Componentverifyticket:"+Ticket); Jedis=Pool.Getshardedjedispool ().GetResource (); Jedis.Set("Componentverifyticket", ticket); }}} catch (Exception e) {E.Printstacktrace (); }return NULL; }
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
How third-party platforms accept authorized public number cancellation authorization event