问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

ios 微信的openid有效期是多久

发布网友 发布时间:2022-04-24 18:49

我来回答

1个回答

热心网友 时间:2023-11-03 19:16

获取微信OpenId 先获取code 再通过code获取authtoken,从authtoken中取出openid给前台 微信端一定不要忘记设定网页账号中的授权回调页面域名 流程图如下 主要代码 页面js代码 /* 写cookie */ function setCookie(name, value) { var Days = 30; var exp = new Date(); exp/connect/oauth2/authorize?appid=") /sns/oauth2/access_token?"; StringBuffer url = new StringBuffer(uri); url.URL; public class HttpClientUtil { // 设置body体 public static void setBodyParameter(String sb, HttpURLConnection conn) throws IOException { DataOutputStream out = new DataOutputStream(conn.getOutputStream()); out.writeBytes(sb); out.flush(); out.close(); } // 添加签名header public static HttpURLConnection CreatePostHttpConnection(String uri) throws MalformedURLException, IOException, ProtocolException { URL url = new URL(uri); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setUseCaches(false); conn.setDoInput(true); conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setInstanceFollowRedirects(true); conn.setConnectTimeout(30000); conn.setReadTimeout(30000); conn.setRequestProperty("Content-Type","application/json"); conn.setRequestProperty("Accept-Charset", "utf-8"); conn.setRequestProperty("contentType", "utf-8"); return conn; } public static byte[] readInputStream(InputStream inStream) throws Exception { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len = 0; while ((len = inStream.read(buffer)) != -1) { outStream.write(buffer, 0, len); } byte[] data = outStream.toByteArray(); outStream.close(); inStream.close(); return data; } } 封装AuthToken的VO类 package com.huatek.shebao.wxpay; public class AuthToken { private String access_token; private Long expires_in; private String refresh_token; private String openid; private String scope; private String unionid; private Long errcode; private String errmsg; public String getAccess_token() { return access_token; } public void setAccess_token(String access_token) { this.access_token = access_token; } public Long getExpires_in() { return expires_in; } public void setExpires_in(Long expires_in) { this.expires_in = expires_in; } public String getRefresh_token() { return refresh_token; } public void setRefresh_token(String refresh_token) { this.refresh_token = refresh_token; } public String getOpenid() { return openid; } public void setOpenid(String openid) { this.openid = openid; } public String getScope() { return scope; } public void setScope(String scope) { this.scope = scope; } public String getUnionid() { return unionid; } public void setUnionid(String unionid) { this.unionid = unionid; } public Long getErrcode() { return errcode; } public void setErrcode(Long errcode) { this.errcode = errcode; } public String getErrmsg() { return errmsg; } public void setErrmsg(String errmsg) { this.errmsg = errmsg; } } 感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

热心网友 时间:2023-11-03 19:16

获取微信OpenId 先获取code 再通过code获取authtoken,从authtoken中取出openid给前台 微信端一定不要忘记设定网页账号中的授权回调页面域名 流程图如下 主要代码 页面js代码 /* 写cookie */ function setCookie(name, value) { var Days = 30; var exp = new Date(); exp/connect/oauth2/authorize?appid=") /sns/oauth2/access_token?"; StringBuffer url = new StringBuffer(uri); url.URL; public class HttpClientUtil { // 设置body体 public static void setBodyParameter(String sb, HttpURLConnection conn) throws IOException { DataOutputStream out = new DataOutputStream(conn.getOutputStream()); out.writeBytes(sb); out.flush(); out.close(); } // 添加签名header public static HttpURLConnection CreatePostHttpConnection(String uri) throws MalformedURLException, IOException, ProtocolException { URL url = new URL(uri); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setUseCaches(false); conn.setDoInput(true); conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setInstanceFollowRedirects(true); conn.setConnectTimeout(30000); conn.setReadTimeout(30000); conn.setRequestProperty("Content-Type","application/json"); conn.setRequestProperty("Accept-Charset", "utf-8"); conn.setRequestProperty("contentType", "utf-8"); return conn; } public static byte[] readInputStream(InputStream inStream) throws Exception { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len = 0; while ((len = inStream.read(buffer)) != -1) { outStream.write(buffer, 0, len); } byte[] data = outStream.toByteArray(); outStream.close(); inStream.close(); return data; } } 封装AuthToken的VO类 package com.huatek.shebao.wxpay; public class AuthToken { private String access_token; private Long expires_in; private String refresh_token; private String openid; private String scope; private String unionid; private Long errcode; private String errmsg; public String getAccess_token() { return access_token; } public void setAccess_token(String access_token) { this.access_token = access_token; } public Long getExpires_in() { return expires_in; } public void setExpires_in(Long expires_in) { this.expires_in = expires_in; } public String getRefresh_token() { return refresh_token; } public void setRefresh_token(String refresh_token) { this.refresh_token = refresh_token; } public String getOpenid() { return openid; } public void setOpenid(String openid) { this.openid = openid; } public String getScope() { return scope; } public void setScope(String scope) { this.scope = scope; } public String getUnionid() { return unionid; } public void setUnionid(String unionid) { this.unionid = unionid; } public Long getErrcode() { return errcode; } public void setErrcode(Long errcode) { this.errcode = errcode; } public String getErrmsg() { return errmsg; } public void setErrmsg(String errmsg) { this.errmsg = errmsg; } } 感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

热心网友 时间:2023-11-03 19:16

获取微信OpenId 先获取code 再通过code获取authtoken,从authtoken中取出openid给前台 微信端一定不要忘记设定网页账号中的授权回调页面域名 流程图如下 主要代码 页面js代码 /* 写cookie */ function setCookie(name, value) { var Days = 30; var exp = new Date(); exp/connect/oauth2/authorize?appid=") /sns/oauth2/access_token?"; StringBuffer url = new StringBuffer(uri); url.URL; public class HttpClientUtil { // 设置body体 public static void setBodyParameter(String sb, HttpURLConnection conn) throws IOException { DataOutputStream out = new DataOutputStream(conn.getOutputStream()); out.writeBytes(sb); out.flush(); out.close(); } // 添加签名header public static HttpURLConnection CreatePostHttpConnection(String uri) throws MalformedURLException, IOException, ProtocolException { URL url = new URL(uri); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setUseCaches(false); conn.setDoInput(true); conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setInstanceFollowRedirects(true); conn.setConnectTimeout(30000); conn.setReadTimeout(30000); conn.setRequestProperty("Content-Type","application/json"); conn.setRequestProperty("Accept-Charset", "utf-8"); conn.setRequestProperty("contentType", "utf-8"); return conn; } public static byte[] readInputStream(InputStream inStream) throws Exception { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len = 0; while ((len = inStream.read(buffer)) != -1) { outStream.write(buffer, 0, len); } byte[] data = outStream.toByteArray(); outStream.close(); inStream.close(); return data; } } 封装AuthToken的VO类 package com.huatek.shebao.wxpay; public class AuthToken { private String access_token; private Long expires_in; private String refresh_token; private String openid; private String scope; private String unionid; private Long errcode; private String errmsg; public String getAccess_token() { return access_token; } public void setAccess_token(String access_token) { this.access_token = access_token; } public Long getExpires_in() { return expires_in; } public void setExpires_in(Long expires_in) { this.expires_in = expires_in; } public String getRefresh_token() { return refresh_token; } public void setRefresh_token(String refresh_token) { this.refresh_token = refresh_token; } public String getOpenid() { return openid; } public void setOpenid(String openid) { this.openid = openid; } public String getScope() { return scope; } public void setScope(String scope) { this.scope = scope; } public String getUnionid() { return unionid; } public void setUnionid(String unionid) { this.unionid = unionid; } public Long getErrcode() { return errcode; } public void setErrcode(Long errcode) { this.errcode = errcode; } public String getErrmsg() { return errmsg; } public void setErrmsg(String errmsg) { this.errmsg = errmsg; } } 感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
抖音弹幕怎么关掉?怎么关闭抖音弹幕? 惠普LaserJet P3005D是否支持B5纸的双面打印? word打印出图片总是缺一部分怎么办-word打印图片不完整怎么解决_百度... 理想one哪里产的车辆? 抚州抚州ONE在哪里? one地址在哪里? 如何在图片上写字(如何在图片上添加文字) 网商贷为什么钱没到账 高级经济师职称怎么评 高级经济师需要评审吗 汽车一开空调前挡风玻璃外边就有一大片水珠,怎么办? 微信的openid长度是28位吗 qq和微信的openid长度分别是多少 qq和微信的openid长度分别是多少? asp怎么解密 这样的 <%@ LANGUAGE = VBScript.Encode %> 齿+可怎么读?怎么在word文档中打出此字? 安卓手机未root怎样查看wifi密码 求周星驰拍的鹿鼎记1,求百度云下载地址 华为HWBK图片文件怎么删除 怎样把电脑里的HWbK照片改为jpg 荣耀手机照片里出现大量后缀名为hwbk的文件 大神有解决的私聊我都可 ... 华为手机p10导照片到电脑出现HWBK格式,怎么变成JPG 手机图库照片怕丢失怎么办? 进行血常规和肝功能体检时,结果RBC平均体积、RBC平均Hb量、血小板都偏高是什么原因? wbk文件怎么打开 华为hb4742aorbc如何刷机 华为手机出现hwbk后缀名的文件,删除不了,好烦啊 华为hb4742a0rbc电池是什么型号 为什么别人看不到我的微博评论? 爱剪辑这个软件有在线剪辑的功能吗? 微信服务器地址?在线等 微信获取openid的问题 微信定机票的时候 出来一个openid为空是什么意思啊 微信用户openid获取的方式有几种 鸽子的生活习性外形特征特长 什么软件可以在视频通话中搜题? 网课搜题用哪一款APP好? 我家的冰箱冷藏室的通风口被冰堵塞,怎么办呢? 三星对开门冰箱,光合保鲜层的通风眼冻冰了,是什么原因,如何处理? 小规模纳税人个人所得税怎么申报 冰箱结了一大块冰怎么办 小规模纳税人怎么申报增值税啊?急 小规模纳税人申报具体步骤 国有四大银行都周末休班吗 增值税小规模纳税人网上申报怎么填? 兴纪龙铝合金衬塑复合管怎么卖的? 铝合金衬塑PE-RT II型复合管和铝合金衬塑PE-RT管有差别吗,价格怎么样? 中国银行的休息制度是什么呀? 急“怎么申请小规模纳税人? 为什么广东的铝合金衬塑(PE-RT)复合管比江苏铝合金衬塑(PE-RT)复合管便宜?