关键字:微信公众平台 微接口 接口100 API100 接口大全
作者:方倍工作室
原文:http://www.cnblogs.com/txw1958/p/weixin-api100.html
在这篇教程中,我们介绍方倍工作室开发的接口以及如何在微信公众平台调用这些接口实现相应的功能。
所有的返回与微信接口一致,详见微信公众平台开发入门教程
接口调用说明:
① Appkey填写为自己的微信公众账号名。
② 免费用户每天最大调用次数为2000次。
③ 请在所有消息底部加上“技术支持 方倍工作室”。
④
⑤
⑥
⑦
⑧
⑨
⑩
⑪
⑫
⑬
⑭
⑮
⑯
⑰
⑱
⑲
⑳
使用举例:
团购代码
php /* 方倍工作室 CopyRight 2013 All Rights Reserved */ define("TOKEN", "weixin"); $wechatObj = new wechatCallbackapiTest(); if (!isset($_GET['echostr'])) { $wechatObj->responseMsg(); }else{ $wechatObj->valid(); } class wechatCallbackapiTest { public function valid() { $echoStr = $_GET["echostr"]; if($this->checkSignature()){ echo $echoStr; exit; } } private function checkSignature() { $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $token = TOKEN; $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr); $tmpStr = implode($tmpArr); $tmpStr = sha1($tmpStr); if($tmpStr == $signature){ return true; }else{ return false; } } public function responseMsg() { $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; if (!empty($postStr)){ $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $RX_TYPE = trim($postObj->MsgType); switch ($RX_TYPE) { case "text": $resultStr = $this->receiveText($postObj); break; case "event": $resultStr = $this->receiveEvent($postObj); break; default: $resultStr = ""; break; } echo $resultStr; }else { echo ""; exit; } } private function receiveText($object) { $keyword = trim($object->Content); $url = "http://api100.duapp.com/groupon/?appkey=trialuser&city=%E6%B7%B1%E5%9C%B3&keyword=%E5%8D%8E%E5%BC%BA%E5%8C%97"; $output = file_get_contents($url); $contentStr = json_decode($output, true); if (is_array($contentStr)){ $resultStr = $this->transmitNews($object, $contentStr); }else{ $resultStr = $this->transmitText($object, $contentStr); } return $resultStr; } private function receiveEvent($object) { $contentStr = ""; switch ($object->Event) { case "subscribe": $contentStr = "欢迎关注"; break; default: break; } $resultStr = $this->transmitText($object, $contentStr); return $resultStr; } private function transmitText($object, $content) { $textTpl = ""; $resultStr = sprintf($textTpl, $object->FromUserName, $object->ToUserName, time(), $content); return $resultStr; } private function transmitNews($object, $arr_item) { if(!is_array($arr_item)) return; $itemTpl = " %s - "; $item_str = ""; foreach ($arr_item as $item) $item_str .= sprintf($itemTpl, $item['Title'], $item['Description'], $item['PicUrl'], $item['Url']); $newsTpl = "
$item_str "; $resultStr = sprintf($newsTpl, $object->FromUserName, $object->ToUserName, time(), count($arr_item)); return $resultStr; } } ?> %s %s
001. 天气预报
city:城市名,传递时须做urlencode http://api100.duapp.com/weather/?appkey=trialuser&city=%E6%B7%B1%E5%9C%B3
002. 空气质量指数
city:城市名,传递时须做urlencode http://api100.duapp.com/airquality/?appkey=trialuser&city=%E6%B7%B1%E5%9C%B3
003. 快递查询
company:快递公司英文代码 点击查看英文代码列表 number:快递单号 http://api100.duapp.com/express/?appkey=trialuser&company=yuantong&number=3143490877
004. 智能快递查询
number:快递单号 http://api100.duapp.com/expressauto/?appkey=trialuser&number=3143490877 备注:支持EMS,申通快递,圆通快递,中通快递,汇通快递,天天快递,韵达快递,顺丰快递,宅急送,速尔快递,德邦物流,联昊通物流,全峰快递,中国邮政
005. 股票查询
code:股票代码[通达信代码] http://api100.duapp.com/stock/?appkey=trialuser&code=000063
006. 股票分析
code:股票代码 http://api100.duapp.com/stockanalysis/?appkey=trialuser&code=000063
007. 公交线路
city:城市名,传递时须做urlencode line:线路,传递时须做urlencode http://api100.duapp.com/busline/?appkey=trailuser&city=%E6%B7%B1%E5%9C%B3&line=209
008. 公交、地铁换乘
city:城市名,传递时须做urlencode start:起点,传递时须做urlencode end:终点,传递时须做urlencode http://api100.duapp.com/bus/?appkey=trailuser&city=%E6%B7%B1%E5%9C%B3&start=%E4%B8%96%E7%95%8C%E4%B9%8B%E7%AA%97&end=%E7%AB%B9%E5%AD%90%E6%9E%97
009. 地铁查询
009. 火车站点
去哪儿:http://touch.qunar.com/h5/train/ 携程:http://m.ctrip.com/html5/Trains/
010. 汽车查询
011. 自驾线路
startcity:起点城市,传递时须做urlencode startplace:起点地名,传递时须做urlencode endcity:终点城市,传递时须做urlencode endplace:终点地名,传递时须做urlencode http://api100.duapp.com/driving/?appkey=trailuser&startcity=%E5%8C%97%E4%BA%AC&startplace=%E6%B8%85%E5%8D%8E%E5%A4%A7%E5%AD%A6&endcity=%E5%8C%97%E4%BA%AC&endplace=%E5%A4%A9%E5%AE%89%E9%97%A8
012. 出租车费用
city:城市名,传递时须做urlencode start:起点,传递时须做urlencode end:终点,传递时须做urlencode http://api100.duapp.com/taxi/?appkey=trailuser&city=%E5%8C%97%E4%BA%AC&start=%E6%B8%85%E5%8D%8E%E5%A4%A7%E5%AD%A6&end=%E5%A4%A9%E5%AE%89%E9%97%A8
011. 航班状态
number:航班号 http://api100.duapp.com/flight/?appkey=trialuser&number=ca1111
013. 笑话
http://api100.duapp.com/joke/?appkey=trialuser
013. 周公解梦
content: 梦见内容,传递时须做urlencode http://api100.duapp.com/dream/?appkey=trialuser&content=%E8%80%81%E5%B8%88
014. 中英互译
content: 翻译内容,传递时须做urlencode http://api100.duapp.com/translate/?appkey=trialuser&content=%E8%A1%A8%E7%A4%BA
015. 星座运势
name: 星座名,传递时须做urlencode http://api100.duapp.com/astrology/?appkey=trialuser&name=%E7%99%BD%E7%BE%8A%E5%BA%A7
016. 彩票开奖结果
name:彩票名称,传递时须做urlencode http://api100.duapp.com/lottery/?appkey=trailuser&name=%E5%8F%8C%E8%89%B2%E7%90%83 备注:支持双色球,大乐透,3D,排列3,排列5,七星彩,七乐彩,胜负彩,任选九,六场半全场,四场进球
017. 苹果IMEI/序列号
number: IMEI号或序列号 接口1:http://api100.duapp.com/apple1/?appkey=trialuser&number=358031058974471 接口2:http://api100.duapp.com/apple2/?appkey=trialuser&number=358031058974471 接口3:http://api100.duapp.com/apple/?appkey=trialuser&number=358031058974471
018. 百科全书
019. 图书介绍
name: 图书名,传递时须做urlencode http://api100.duapp.com/book/?appkey=trialuser&name=%E7%9B%97%E5%A2%93%E7%AC%94%E8%AE%B0
020. 音乐介绍
name: 音乐名,传递时须做urlencode http://api100.duapp.com/music/?appkey=trialuser&name=%E6%96%B0%E5%B9%B4%E5%A5%BD
021. 电影介绍
name: 电影名,传递时须做urlencode http://api100.duapp.com/movie/?appkey=trialuser&name=%E9%BE%99%E7%8C%AB
022. 历史上的今天
http://api100.duapp.com/history/?appkey=trialuser
023. 经济指标
024. 财经大事
025. 食物热量
026. 城市团购
city: 城市名,传递时须做urlencode,你可以指定一个固定城市 查看支持城市列表 keyword:关键字,传递时须做urlencode,可为商户名、商品名、地址等 http://api100.duapp.com/groupon/?appkey=trialuser&city=%E6%B7%B1%E5%9C%B3&keyword=%E5%8D%8E%E5%BC%BA%E5%8C%97
027. 城市优惠
028. 黄金
029. 白银
030. 外汇
030. 图片检索
031. 视频检索
032. 地图位置服务
lat:纬度 lng:经度 entity:查询名称,传递时须做urlencode http://api100.duapp.com/map/?appkey=trialuser&lat=39.915&lng=116.404&entity=%E5%8C%BB%E9%99%A2
033. 菜谱
name: 菜谱名称,传递时须做urlencode http://api100.duapp.com/recipe/?appkey=trialuser&name=%E5%89%81%E6%A4%92%E9%B1%BC%E5%A4%B4
036. 手机号码归属地
037. 身份证归属查询
037. 电视节目表
038. IP地址
039. 黄历每日宜忌
040. 产品报价
041. 号码吉凶
042. 邮政编码
043. 一淘比价
044. 食物热量
045. 人品计算
更新日志:
2013.09.01 发布第一版
......
2013.12.16 优化历史上的今天
2013.12.20 增加彩票查询