[1].[代码]获取授权签名链接
function seturl(url){
varnewUrl = encodeURIComponent(url);
varreNewUrl ='https://open.weixin.qq.com/connect/oauth2/authorize?appid=${(AppId)!}&redirect_uri='+ newUrl +'&response_type=code&scope=snsapi_base&state=123#wechat_redirect';
}
public String getopendid(String code) {
String url ="https://api.weixin.qq.com/sns/oauth2/access_token?appid=AppId&secret=AppSecret&code=CODE&grant_type=authorization_code";
url = url.replace("AppId", AppId).replace("AppSecret", AppSecret)
.replace("CODE", code);
String jsonResult = HttpKit.get(url);
JSONObject jsonTexts = (JSONObject) JSON.parse(jsonResult);
String openid ="";
if(StringKit.notNull(jsonTexts.get("openid"))) {
openid = jsonTexts.get("openid").toString();
}
returnopenid;
}
原文 http://www.oschina.net/code/snippet_2255303_46155
网友评论