How long is the openid of ios WeChat valid?
To get WeChat OpenId, first get the code, and then get authtoken through the code. Take openid out of authtoken and give it to WeChat at the front desk. Don't forget to set the domain name flow chart of the authorized callback page in the webpage account. Main code page jscode/* writecookie */functionset cookie (name, value) {vardays = 30; var exp = new Date(); exp/connect/oauth2/authorize? appid = ")/SNS/oauth 2/access _ token?" ; string buffer URL = new string buffer(uri); Website. Website; The public class HttpClientUtil {//sets body public static void setbodyparameter (string sb, HttpURLConnection conn) throws IOException {DataoutputStream Out = New DataoutputStream (conn.getoutputStream ())); out . write bytes(sb); out . flush(); out . close(); }//Add signature header public static httpurl connection createposthttpconnection (string URI) throws MalformedulException, IoException, ProtocolException {URL URL = NewURL (uri); HttpURLConnection conn =(http urlconnection)URL . open connection(); conn . setusecaches(false); conn . setdoinput(true); conn . setdoooutput(true); conn . setrequestmethod(" POST "); conn . setinstancefolredirects(true); conn . setconnecttimeout(30000); conn . setreadtimeout(30000); conn . setrequestproperty(" Content-Type "," application/JSON "); conn . setrequestproperty(" Accept-Charset "," utf-8 "); conn . setrequestproperty(" content type "," utf-8 "); Return connector; } public static byte [] read input stream (input stream instream) throws an exception {bytearray outputstream = new bytearray outputstream (); Byte[] buffer = new byte [1024]; int len = 0; while((len = instream . read(buffer))! =- 1){ outstream . write(buffer,0,len); } byte[]data = out stream . tobytearray(); out stream . close(); instream . close(); Return data; }} VO class package com. huatek.shebao.wxpay that encapsulates AuthToken; Public class AuthToken {private string access _ token private long expires _ in private string refresh _ token private string openid private string range; Private string unionid private long error code; Private string errmsg public string getaccess _ token () {returnaccess _ token; } public void set access _ token(String access _ token){ this . access _ token = access _ token; } public Long get expires _ in(){ return expires _ in; } public void set expires _ in(Long expires _ in){ this . expires _ in = expires _ in; } public String get refresh _ token(){ return refresh _ token; } public void set refresh _ token(String refresh _ token){ this . refresh _ token = refresh _ token; } public string getOpenID () {returnOpenID; } public void setopen id(String OpenID){ this . OpenID = OpenID; } public string getscope () {returnscope; } public void set scope(String scope){ this . scope = scope; } public string getunionid () {returnunionid; } public void setUnionid(String unionid){ this . unionid = unionid; } public Long getErrcode(){ return errcode; } public void setErrcode(Long errcode){ this . errcode = errcode; } public string geterrmsg () {returnerrmsg; } public void setErrmsg(String errmsg){ this . errmsg = errmsg; Thank you for reading, I hope I can help you, and thank you for your support to this site!