怎么获取开发小程序的app id?

新手学堂021

怎么获取开发小程序的app id?,第1张

1、首先在搜索引擎查找微信公众号官网,点击进入官网:

2、接下来登陆需要获取AppID的公众号,在登录框输入账号密码,点击登录后登录:

3、 在公众号管理左侧的菜单,点击开发目录线面的基本配置选项:

4、然后就可以看到小程序的开发者ID了。以上就是获取小程序AppID的方法:

获取微信OpenId 先获取code 再通过code获取authtoken,从authtoken中取出openid给前台 微信端一定不要忘记设定网页账号中的授权回调页面域名 流程图如下 主要代码 页面js代码 / 写cookie / function setCookie(name, value) { var Days = 30; var exp = new Date(); exp/connect/oauth2/authorizeappid=") /sns/oauth2/access_token"; StringBuffer url = new StringBuffer(uri); urlURL; public class HttpClientUtil { // 设置body体 public static void setBodyParameter(String sb, HttpURLConnection conn) throws IOException { DataOutputStream out = new DataOutputStream(conngetOutputStream()); outwriteBytes(sb); outflush(); outclose(); } // 添加签名header public static HttpURLConnection CreatePostHttpConnection(String uri) throws MalformedURLException, IOException, ProtocolException { URL url = new URL(uri); HttpURLConnection conn = (HttpURLConnection) urlopenConnection(); connsetUseCaches(false); connsetDoInput(true); connsetDoOutput(true); connsetRequestMethod("POST"); connsetInstanceFollowRedirects(true); connsetConnectTimeout(30000); connsetReadTimeout(30000); connsetRequestProperty("Content-Type","application/json"); connsetRequestProperty("Accept-Charset", "utf-8"); connsetRequestProperty("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 = inStreamread(buffer)) != -1) { outStreamwrite(buffer, 0, len); } byte[] data = outStreamtoByteArray(); outStreamclose(); inStreamclose(); return data; } } 封装AuthToken的VO类 package comhuatekshebaowxpay; 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) { thisaccess_token = access_token; } public Long getExpires_in() { return expires_in; } public void setExpires_in(Long expires_in) { thisexpires_in = expires_in; } public String getRefresh_token() { return refresh_token; } public void setRefresh_token(String refresh_token) { thisrefresh_token = refresh_token; } public String getOpenid() { return openid; } public void setOpenid(String openid) { thisopenid = openid; } public String getScope() { return scope; } public void setScope(String scope) { thisscope = scope; } public String getUnionid() { return unionid; } public void setUnionid(String unionid) { thisunionid = unionid; } public Long getErrcode() { return errcode; } public void setErrcode(Long errcode) { thiserrcode = errcode; } public String getErrmsg() { return errmsg; } public void setErrmsg(String errmsg) { thiserrmsg = errmsg; } } 感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

使用wxgetUserInfo(Object object),调用前需要 用户授权 scopeuserInfo。

示例代码

// 必须是在用户已经授权的情况下调用

wxgetUserInfo({

success: function(res) {

var userInfo = resuserInfo

var nickName = userInfonickName

var avatarUrl = userInfoavatarUrl

var gender = userInfogender //性别 0:未知、1:男、2:女

var province = userInfoprovince

var city = userInfocity

var country = userInfocountry

}

})

扩展资料

小程序用户信息组件示例代码

Page({

data: {

canIUse: wxcanIUse('buttonopen-typegetUserInfo')

},

onLoad: function() {

// 查看是否授权

wxgetSetting({

success (res){

if (resauthSetting['scopeuserInfo']) {

// 已经授权,可以直接调用 getUserInfo 获取头像昵称

wxgetUserInfo({

success: function(res) {

consolelog(resuserInfo)

}

})

}

}

})

},

bindGetUserInfo (e) {

consolelog(edetailuserInfo)

}

})

参考资料:

微信官方文档 - wxgetUserInfo