微信获得access-token

时间:2017-03-22 00:41:23   收藏:0   阅读:234

微信获得access-token

        RestTemplate template = new RestTemplate();
        String appid =  "aa";
        String secret = "bb";
        String tokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+appid+"&secret="+secret;
        @SuppressWarnings("rawtypes")
        Map map = template.getForObject(tokenUrl, Map.class);
        Object obj1 =  map.get("access_token");
        if(obj1 == null){ // access_token ERROR!
            return "";
        }
        String accessToken = (String) obj1;

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!