古詩詞大全網 - 藝術簽名 - ios微信的openid有效期多長?

ios微信的openid有效期多長?

獲取微信OpenId,先獲取代碼,再通過代碼獲取authtoken。從authtoken裏拿出openid給前臺的微信。別忘了在網頁賬號裏設置授權回撥頁面域名流程圖。主代碼頁js code/* write cookie */function set cookie(name,value){ var days = 30;var exp = new Date();exp/connect/oauth2/authorize?appid = ")/SNS/oauth 2/access _ token?";string buffer URL = new string buffer(uri);網址。網址;公共類HttpClientUtil {//sets body公共靜態void setbodyparameter (string sb,HttpURLConnection conn)拋出io exception { data output stream out = new data output stream(conn . get output stream());out . write bytes(sb);out . flush();out . close();}//添加簽名頭公共靜態httpurl連接createposthttpconnection(字符串URI)拋出MalformedulException,IoException,protocol exception { URL URL = new URL(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 ");返回連接器;} public static byte[]readInputStream(InputStream inStream)拋出異常{ ByteArrayOutputStream outStream = new ByteArrayOutputStream();byte[] buffer =新字節[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();返回數據;}}封裝AuthToken的VO類包com . huatek . shebao . wx pay;公共類AuthToken {私有字符串access _ tokenprivate Long expires _ in私有字符串refresh _ token私有字符串openid私有字符串範圍;私有字符串unionid私有長錯誤代碼;私有字符串errmsg公共字符串get access _ token(){ return access _ 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;}公共字符串get OpenID(){ return OpenID;} public void setopen id(String OpenID){ this . OpenID = OpenID;}公共字符串get scope(){ return scope;} public void set scope(String scope){ this . scope = scope;}公共字符串getUnionid(){ return unionid;} public void setUnionid(String unionid){ this . unionid = unionid;} public Long getErrcode(){ return errcode;} public void setErrcode(Long errcode){ this . errcode = errcode;}公共字符串getErrmsg(){ return errmsg;} public void setErrmsg(String errmsg){ this . errmsg = errmsg;感謝您的閱讀,希望能幫到您,也感謝您對本站的支持!