Loading

微信获得access-token

微信获得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;

 

posted @ 2017-03-21 23:14  stono  阅读(208)  评论(0编辑  收藏  举报