-------------------------------------------------------------------------官方文档说明开始-----------------------------------------------------------------------------------
java
该API用于获取预受权码。预受权码用于公众号受权时的第三方平台方安全验证。json
http请求方式: POST(请使用https协议)api
https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token=xxx安全
POST数据示例:app
{
"component_appid":"appid_value"
}
this
参数 | 说明 |
---|---|
component_appid | 第三方平台方appid |
{
url
"pre_auth_code":"Cx_Dk6qiBE0Dmx4EmlT3oRfArPvwSQ-oa3NL_fwHM7VI08r52wazoZX2Rhpz1dEw",
"expires_in":600
}
参数 | 说明 |
---|---|
pre_auth_code | 预受权码 |
expires_in | 有效期,为20分钟 |
/** * 二、获取预受权码 * * 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"); }
/** * 二、获取预受权码 * * 该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; } }
版权声明:本文为博主原创文章,未经博主容许不得转载。spa