-------------------------------------------------------------------------官方文档说明开始-----------------------------------------------------------------------------------
该API用于获取预授权码。预授权码用于公众号授权时的第三方平台方安全验证。
http请求方式: POST(请使用https协议)
https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token=xxx
POST数据示例:
{
"component_appid":"appid_value"
}
参数 | 说明 |
---|---|
component_appid | 第三方平台方appid |
{
"pre_auth_code":"Cx_Dk6qiBE0Dmx4EmlT3oRfArPvwSQ-oa3NL_fwHM7VI08r52wazoZX2Rhpz1dEw",
"expires_in":600
}
参数 | 说明 |
---|---|
pre_auth_code | 预授权码 |
expires_in | 有效期,为20分钟 |
/** * 2、获取预授权码 * * http请求方式: POST(请使用https协议) * * https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode? * component_access_token=xxx * * POST数据示例: { "component_appid":"appid_value" } */ public static String getPre_auth_code() { String url = "https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token=" + getToken(); Pre_auth_code pre = new Pre_auth_code(); pre.setComponent_appid("*****"); JSONObject jsonObject = WeixinUtil.httpRequest(url, "POST", JSONObject.fromObject(pre).toString()); System.out.println("获取的预授权码为: " + jsonObject.toString()); return jsonObject.getString("pre_auth_code"); }
/** * 2、获取预授权码 * * 该API用于获取预授权码。预授权码用于公众号授权时的第三方平台方安全验证。 * * @author YangChao * */ public class Pre_auth_code { // 第三方平台方appid private String component_appid; public String getComponent_appid() { return component_appid; } public void setComponent_appid(String component_appid) { this.component_appid = component_appid; } }
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/yangchao13341408947/article/details/48023941