本人的返回API文本消息测试部分java代码如下:
//模拟粉丝发送文本消息给专用测试公众号,第三方平台方需在5秒内返回空串表明暂时不回复,然后再立即使用客服消息接口发送消息回复粉丝(content为:QUERY_AUTH_CODE:$query_auth_code$)
respMessage = “”;
String queryAuthCode = “”;//授权码
String content = msgReceive.getContent();
if(content.contains(“:”)){
queryAuthCode = content.split(“:”)[1]==null?””:content.split(“:”)[1];
}
SysCompVerifyTicket sysCompVerifyTicket = new SysCompVerifyTicket();
sysCompVerifyTicket.setAppId(appId);
List<SysCompVerifyTicket> sysCompVerifyTickets = sysCompVerifyTicketService.getSysCompVerifyTicketEntity(sysCompVerifyTicket);
String compVerifyTicket = “”;
if(null != sysCompVerifyTickets && sysCompVerifyTickets.size()>0){
compVerifyTicket = sysCompVerifyTickets.get(0).getCompVerifyTicket();
}
String outputStr = “{“component_appid”:””+appId+””,”component_appsecret”:””+appSecret+””,”component_verify_ticket”:””+compVerifyTicket+””}”;
JSONObject jsonCmpToken = CoreUtil.httpRequest(“https://api.weixin.qq.com/cgi-bin/component/api_component_token”, SystemUtil.POST, outputStr);
if(!jsonCmpToken.containsKey(“component_access_token”)){
return “”;
}
String compAccessToken = jsonCmpToken.get(“component_access_token”).toString();//第三方平台令牌
outputStr = null;
outputStr = “{“component_appid”:””+appId+””,”authorization_code”:””+queryAuthCode+””}”;
JSONObject json = CoreUtil.httpRequest(“https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token=”+compAccessToken, SystemUtil.POST, outputStr);
if(null != json && json.containsKey(“authorization_info”)){
JSONObject jsonAuthInfo = (JSONObject)json.get(“authorization_info”);
if(null != jsonAuthInfo && jsonAuthInfo.containsKey(“authorizer_access_token”)){
String authorizer_access_token = jsonAuthInfo.get(“authorizer_access_token”).toString();//授权access_token
String url = CoreUtil.getCustemServiceUrl(authorizer_access_token);
String jsonString = “{“ToUserName”:””+msgReceive.getFromUserName()+””,”FromUserName”:””+msgReceive.getToUserName()+””,”CreateTime”:””+DateUtil.getLongFromDate(new Date())+””,”MsgType”:”text”,”Content”:””+queryAuthCode + “_from_api”+””}”;
JSONObject customerResult = CoreUtil.httpRequest(url, “POST”, jsonString);
}
}
customerResult 返回一直是报 invilid openid 实在看不出问题在哪了 求指点指点。