How third-party platforms accept authorized public number cancellation authorization event

Source: Internet
Author: User
Tags cdata

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.