公衆號自定義菜單獲取用戶信息

一、網頁授權
在這裏插入圖片描述

在這裏插入圖片描述
下載文件放置在項目根目錄。

1、js獲取公衆號中用戶code

//獲取公衆號code
function getQueryString(name) {
  		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null){
            return unescape(r[2]);
		 }
    return null;
}

2、java後臺獲取用戶code
在這裏插入圖片描述
3、code獲取用戶信息openid

        String url="https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx6ff234c5c2e1d45&secret=d56ab881d00d32423523234326fd6e1ecb&code="+code+"&grant_type=authorization_code";

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章