公用号微信接口测试平台台可以测试微店接口吗

android开发(52)
京东获取单个商品价格接口:
/prices/mgets?skuIds=J_商品ID&type=1
ps:商品ID这么获取:/954086.html
/query?type=快递公司代号&postid=快递单号
ps:快递公司编码:申通=&shentong& EMS=&ems& 顺丰=&shunfeng& 圆通=&yuantong& 中通=&zhongtong& 韵达=&yunda& 天天=&tiantian& 汇通=&huitongkuaidi& 全峰=&quanfengkuaidi& 德邦=&debangwuliu& 宅急送=&zhaijisong&
FeedXml转json接口:
/ajax/services/feed/load?q=Feed地址&v=1.0
备选参数:callback:&callback=foo就会在json外面嵌套foo({})方便做jsonp使用。
备选参数:n:返回多少条记录。
http://api./telematics/v3/weather?location=嘉兴&output=json&ak=5slgyqGDENN7Sy7pw29IUvrZ
location:城市名或经纬度 ak:开发者密钥 output:默认xml
气象局接口:
.cn/data/.html
/app/nineteen/search/key/歌曲名称/diandian/1/page/歌曲当前页?_=当前毫秒&callback=getXiamiData
QQ空间音乐接口
http://qzone-/fcg-bin/cgi_playlist_xml.fcg?uin=QQ号码&json=1&g_tk=
QQ空间收藏音乐接口
http://qzone-/fcg-bin/fcg_music_fav_getinfo.fcg?dirinfo=0&dirid=1&uin=QQ号&p=0.262&g_tk=
多米音乐接口
http://v5./search-ajaxsearch-searchall?kw=关键字&pi=页码&pz=每页音乐数
http://cgi./fcgi-bin/fcg_search_xmldata.q?source=10&w=关键字&perpage=1&ie=utf-8
/v3/gw?method=album.item.get&appKey=Appkey&format=json&albumId=视频剧集ID&pageNo=当前页&pageSize=每页显示
阿里云根据地区名获取经纬度接口
http://gc./geocoding?a=苏州市
参数解释: 纬度,经度type 001 (100代表道路,010代表POI,001代表门址,111可以同时显示前三项)
阿里云根据经纬度获取地区名接口
http://gc./regeocoding?l=39..395739&type=001
新浪接口(ip值为空的时候 获取本地的)
http://int..cn/iplookup/iplookup.php?format=json&ip=218.4.255.255
/service/getIpInfo.php?ip=63.223.108.42
手机信息查询接口
淘宝网接口
/cc/json/mobile_tel_segment.htm?tel=手机号
/extinfo/GetMobileProductInfo?mobile=手机号&amount=10000&callname=getPhoneNumInfoExtCallback
百付宝接口
/callback?cmd=1059&callback=phone&phone=手机号
/?ct=index&ac=get_mobile_local&callback=jsonp1&mobile=手机号
/smartresult-xml/search.s?jsFlag=true&type=mobile&q=手机号
手机在线接口
/Locating/.aspx?m=手机号&output=json&callback=querycallback
视频信息接口
/player/getPlayList/VideoIDS/视频ID (比如 /v_show/id_XNTQxNzc4ODg0.html的ID就是XNTQxNzc4ODg0)
翻译、词典接口
/dict?q=词语
腾讯的部分接口
获取QQ昵称和用户头像
http://r./cgi-bin/user/cgi_personal_card?uin=QQ(不过是jsonp哦)
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:30201次
排名:千里之外
原创:42篇
转载:36篇
QQ咨询: QQ咨询: 最新电影网:
(1)(1)(2)(1)(1)(2)(6)(5)(41)(21)你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
微信公众号第三方平台的开放,让公众号运营者在面向垂直行业需求时,可以通过一键登录授权给第三方开发者,来完成相关的处理能力,方便快捷,那如何才能开发出一个公众号第三方平台供一键授权呢?本文以JAVA作为后台服务的实现语言,实现了微信第三方开放平台开发所需要的主要业务流程,并针对全网发布的检测做了相应的代码处理,以通过微信全网检测,可以接入任意的微信公众号。
根据微信第三方平台的审核需求,你需要在微信开放平台上注册第三方平台信息时,提供如下几个主要的服务:
1、授权事件接收服务,对应填写的审核资料中授权事件接收URL,微信会将相关的授权事件信息推送到该REST服务上,推送的主要消息包括验证票据ComponentVerifyTicket和取消授权的公众号AuthorizerAppid,该服务需要对微信推送过来的该类消息立即做出回应并返回success内容,该服务事件的JAVA实现方式如下:
* 授权事件接收
* @param request
* @param response
* @throws IOException
* @throws AesException
* @throws DocumentException
@RequestMapping(value = &/open/event/authorize&, method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void acceptAuthorizeEvent(HttpServletRequest request, HttpServletResponse response) throws IOException, AesException, DocumentException {
WeixinOpenService.getInstance().processAuthorizeEvent(request);
WeixinOpenService.getInstance().output(response, &success&); // 输出响应的内容。
更具体的实现代码如下:
* 处理授权事件的推送
* @param request
* @throws IOException
* @throws AesException
* @throws DocumentException
public void processAuthorizeEvent(HttpServletRequest request) throws IOException, DocumentException, AesException {
String token = WeixinOpenService.TOKEN;
String nonce = request.getParameter(&nonce&);
String timestamp = request.getParameter(&timestamp&);
String signature = request.getParameter(&signature&);
String msgSignature = request.getParameter(&msg_signature&);
if (!StringUtils.isNotBlank(msgSignature))
// 微信推送给第三方开放平台的消息一定是加过密的,无消息加密无法解密消息
boolean isValid = WechatCallbackServiceController.checkSignature(token, signature, timestamp, nonce);
if (isValid) {
StringBuilder sb = new StringBuilder();
BufferedReader in = request.getReader();
while ((line = in.readLine()) != null) {
sb.append(line);
String xml = sb.toString();
String encodingAesKey = WeixinOpenService.ENCODINGAESKEY;// 第三方平台组件加密密钥
String appId = getAuthorizerAppidFromXml(xml, &authorizationEvent&);// 此时加密的xml数据中ToUserName是非加密的,解析xml获取即可
WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, appId);
xml = pc.decryptMsg(msgSignature, timestamp, nonce, xml, &AppId&);
processAuthorizationEvent(xml);
2、公众号消息与事件接收服务,对应填写的审核资料中公众号消息与事件接收URL,微信会将粉丝发送给公众号的消息和事件推送到该REST服务上,微信公众平台要求该消息和事件接收服务在5秒内做出回应,如果5秒内微信公众平台得不到响应消息,粉丝将将收到提示公众号暂时服务提供服务的错误信息。对于需要对粉丝发送的消息走人工渠道做出响应的公众号来说,此时就需要首先接收下消息,将消息交给后来逻辑转人工处理,然后立即以空格消息响应微信公众平台,微信收到空格消息后就会知道该粉丝发送的消息已经被妥善处理,并对该响应不做任何处理,同时不会发起消息重新推送的重试。该服务的JAVA实现实现方式如下: /**
* 处理微信推送过来的授权公众号的消息及事件
public void processMessageAndEvent(HttpServletRequest request,String xml) throws IOException, AesException, DocumentException {
String nonce = request.getParameter(&nonce&);
String timestamp = request.getParameter(&timestamp&);
String msgSignature = request.getParameter(&msg_signature&);
String encodingAesKey = WeixinOpenService.ENCODINGAESKEY;
String token = WeixinOpenService.TOKEN;
WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, PONENT_APPID);
xml = pc.decryptMsg(msgSignature, timestamp, nonce, xml, &ToUserName&);
WechatCallbackServiceController.processMessage(xml);
以上是开发微信第三方开发平台的主要服务代码,想要通过微信全网接入检测并成功发布,还有如下的工作的需要做:
开发一个体验页,可以直接让审核人员体验,因为需要的是直接体验,所以访问该页面就不要有认证和权限控制之类的逻辑了,这个页面要求符合微信第三方平台基本的设计要求,本人简单实现了如下的页面格式是可以成功通过审核的,如下:
针对微信全网检测的固定账号做出特定的响应,主要包括一个文本消息响应,一个事件消息响应和一个客服接口调用验证,微信全网检测要求测试的固定账号接收到以上消息后,分别做出如下的响应:接收到TESTCOMPONENT_MSG_TYPE_TEXT这样的文本消息立即回复给粉丝文本内容TESTCOMPONENT_MSG_TYPE_TEXT_callback;接收到事件消息,立即以文本内容的消息格式回复粉丝内容event + “from_callback”,其中event需要根据实际内容替换为具体事件类型;接收到QUERY_AUTH_CODE:query_auth_code
这样的文本消息,需要立即响应空字符串给微信,之后调用客服接口回复粉丝文本消息,内容为:$query_auth_code\$_from_api,其中query_auth_code需要替换为微信实际推送过来的数据。主要的JAVA后台实现代码如下:
* 公众号消息与事件接收
* @param request
* @param response
* @throws DocumentException
* @throws AesException
* @throws IOException
@RequestMapping(value = &/open/{appid}/callback&, method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void acceptMessageAndEvent(HttpServletRequest request, HttpServletResponse response) throws IOException, AesException, DocumentException {
String msgSignature = request.getParameter(&msg_signature&);
if (!StringUtils.isNotBlank(msgSignature))
// 微信推送给第三方开放平台的消息一定是加过密的,无消息加密无法解密消息
StringBuilder sb = new StringBuilder();
BufferedReader in = request.getReader();
while ((line = in.readLine()) != null) {
sb.append(line);
in.close();
String xml = sb.toString();
Document doc = DocumentHelper.parseText(xml);
Element rootElt = doc.getRootElement();
String toUserName = rootElt.elementText(&ToUserName&);
if (StringUtils.equalsIgnoreCase(toUserName, &gh_3c884a361561&)) {// 微信全网测试账号
WeixinWholeNetworkTestService.getInstance().checkWeixinAllNetworkCheck(request,response,xml);
WeixinOpenService.getInstance().processMessageAndEvent(request,xml);
WeixinOpenService.getInstance().output(response, &&);
其中gh_3c884a361561这个账号是微信全网接入检测的固定账号,针对全网检测需要对该账号做特出响应,一旦全网接入检测通过,这部分的代码是可以去掉的,只有全网检测的时候才需要这部分代码。
public void checkWeixinAllNetworkCheck(HttpServletRequest request, HttpServletResponse response,String xml) throws DocumentException, IOException, AesException{
String nonce = request.getParameter(&nonce&);
String timestamp = request.getParameter(&timestamp&);
String msgSignature = request.getParameter(&msg_signature&);
String encodingAesKey = WeixinOpenService.ENCODINGAESKEY;
String token = WeixinOpenService.TOKEN;
WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, PONENT_APPID);
xml = pc.decryptMsg(msgSignature, timestamp, nonce, xml, &ToUserName&);
Document doc = DocumentHelper.parseText(xml);
Element rootElt = doc.getRootElement();
String msgType = rootElt.elementText(&MsgType&);
String toUserName = rootElt.elementText(&ToUserName&);
String fromUserName = rootElt.elementText(&FromUserName&);
switch (msgType) {
case &event&:
String event = rootElt.elementText(&Event&);
replyEventMessage(request,response,event,toUserName,fromUserName);
case &text&:
String content = rootElt.elementText(&Content&);
processTextMessage(request,response,content,toUserName,fromUserName);
根据消息或事件类型区分后,剩余的逻辑只需要处理成对应的回复内容即可,如下:public void replyEventMessage(HttpServletRequest request, HttpServletResponse response, String event, String toUserName, String fromUserName) throws DocumentException, IOException {
String content = event + &from_callback&;
replyTextMessage(request,response,content,toUserName,fromUserName);
public void processTextMessage(HttpServletRequest request, HttpServletResponse response,String content,String toUserName, String fromUserName) throws IOException, DocumentException{
if(&TESTCOMPONENT_MSG_TYPE_TEXT&.equals(content)){
String returnContent = content+&_callback&;
replyTextMessage(request,response,returnContent,toUserName,fromUserName);
}else if(StringUtils.startsWithIgnoreCase(content, &QUERY_AUTH_CODE&)){
WeixinOpenService.getInstance().output(response, &&);
//接下来客服API再回复一次消息
replyApiTextMessage(request,response,content.split(&:&)[1],fromUserName);
public void replyApiTextMessage(HttpServletRequest request, HttpServletResponse response, String auth_code, String fromUserName) throws DocumentException, IOException {
String authorization_code = auth_
// 得到微信授权成功的消息后,应该立刻进行处理!!相关信息只会在首次授权的时候推送过来
WeixinOpenData weixinOpenData = WeixinOpenService.getInstance().PONENT_APPID);
long accessTokenExpires = weixinOpenData.getAccessTokenExpires();
String componentAccessToken = weixinOpenData.getComponentAccessToken();
String componentVerifyTicket = weixinOpenData.getComponentVerifyTicket();
JSONObject authorizationInfoJ
if (!this.isExpired(accessTokenExpires)) {
authorizationInfoJson = WeixinOpenService.getInstance().apiQueryAuth(componentAccessToken, PONENT_APPID, authorization_code);
JSONObject accessTokenJson = WeixinOpenService.getInstance().PONENT_APPID, PONENT_APPSECRET, componentVerifyTicket);
componentAccessToken = accessTokenJson.getString(&component_access_token&);
authorizationInfoJson = WeixinOpenService.getInstance().apiQueryAuth(componentAccessToken, PONENT_APPID, authorization_code);
if (log.isDebugEnabled()) {
log.debug(&weixinopen callback authorizationInfo is & + authorizationInfoJson);
JSONObject infoJson = authorizationInfoJson.getJSONObject(&authorization_info&);
String authorizer_access_token = infoJson.getString(&authorizer_access_token&);
String url = & + authorizer_access_
DefaultHttpClient client = new DefaultHttpClient();
enableSSLDefaultHttpClient(client);
HttpPost httpPost = new HttpPost(url);
JSONObject message = processWechatTextMessage(client, httpPost, fromUserName, auth_code + &_from_api&);
if(log.isDebugEnabled()){
log.debug(&api reply messto to weixin whole network test respose = &+message);
public void replyTextMessage(HttpServletRequest request, HttpServletResponse response, String content, String toUserName, String fromUserName) throws DocumentException, IOException {
Long createTime = Calendar.getInstance().getTimeInMillis() / 1000;
StringBuffer sb = new StringBuffer();
sb.append(&&);
sb.append(&&);
sb.append(&&);
sb.append(&& + createTime + &&);
sb.append(&&);
sb.append(&&);
sb.append(&&);
String replyMsg = sb.toString();
String returnvaleue = &&;
WXBizMsgCrypt pc = new WXBizMsgCrypt(WeixinOpenService.TOKEN, WeixinOpenService.ENCODINGAESKEY, PONENT_APPID);
returnvaleue = pc.encryptMsg(replyMsg, createTime.toString(), &easemob&);
} catch (AesException e) {
log.error(&auto reply to weixin whole network test occur exception = &+ e);
e.printStackTrace();
if(log.isDebugEnabled()){
log.debug(&return weixin whole network test Text message is = &+returnvaleue);
WeixinOpenService.getInstance().output(response, returnvaleue);
以上是微信第三方开放平台开发主要的业务流程,在实际开发中,还有两点需要特别注意:
1、微信要求第三方开放平台必须以密文方式接收消息;
2、在实际部署时,需要更换JAVA安全包相关的内容,否则将出现秘钥长度不够的异常,需要替换的文件包括JAVA_HOME/jre/lib/security/local_policy.jar和
JAVA_HOME/jre/lib/security/US_export_policy.jar这两个文件。
作者:徐正礼
请教一下,我们平台是用PHP开发的,在全网发布的时候遇到了困难。能否帮忙解决,可以带薪,价格好说,请加QQ
求推送component_verify_ticket协议有关的php代码
不过我是PHP写的
比较容易犯错的在api文本这里
第三方平台方拿到$query_auth_code$的值后,通过接口文档页中的“使用授权码换取公众号的授权信息”API,将$query_auth_code$的值赋值给API所需的参数authorization_code。
上面这段话的接口
要使用xml解析出来的 我是这样做的
$AuthorizationCode = $xml-&getElementsByTagName('AuthorizationCode')-&item(0)-&nodeV
把这个获取到的code传到API接口上
然后,调用发送客服消息api回复文本消息给粉丝,其中文本消息的content字段设为:$query_auth_code$_from_api(其中$query_auth_code$需要替换成推送过来的query_auth_code)
然后这个客服的code呢 就使用他 说的这个方法去截取
trim(str_replace(&QUERY_AUTH_CODE:&,&&,$rec_words))
我是php代码写的
大家参考下
如果还是不明白
可以加我微信 qiufeng2983
要回复文章请先或
imgeek管理员
知识价值的认可,源自您的赞赏
扫描二维码,你的支付将由imGeek代收后转给对方
感谢您的赞赏
一个开放、互助、协作、创意的社区
一个开放、互助、协作、创意的社区
京ICP备号-3关于微信公众平台测试号配置失败的问题
在做微信测试的时候,遇到测试失败的问题,如下图:
token值没有问题,wx_sample.php部分代码
在这种情况下出现配置失败。
解决办法:在代码中修改一个地方,即保证代码:$wechatObj-&valid();有执行即可
修改后配置成功:
(window.slotbydup=window.slotbydup || []).push({
id: '2467140',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467141',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467142',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467143',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467148',
container: s,
size: '1000,90',
display: 'inlay-fix'}

我要回帖

更多关于 淘宝接口测试平台 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信