该API用于获取授权方的基本信息,包括头像、昵称、帐号类型、认证类型、微信号、原始ID和二维码图片URL。
需要特别记录授权方的帐号类型,在消息及事件推送时,对于不具备客服接口的公众号,需要在5秒内立即响应;而若有客服接口,则可以选择暂时不响应,而选择后续通过客服接口来发送消息触达粉丝。
代码如下:
/**
* 查询公众号基本信息
* @param appid
*/
public static JSONObject getAuthorizerInfoDetail(String appid) {
JSONObject json = new JSONObject();
json.put("component_appid", component_appid);
json.put("authorizer_appid", appid);
/** 发送Https请求到微信 */
JSONObject resultJson = new JSONObject();
try {
String url= "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=%s";
resultJson = HttpClientUtil.postJson(String.format(url, getComponentAccessToken()), json);
} catch (ConnectException | SocketTimeoutException e) {
LOGGER.error(e.toString());
}
return resultJson;
}