我看到有些公众平台比如:海南大学 功能非常丰富,包含四六级成绩查询、自习室空位查询、小i机器人、天气查询、快递查询、笑话、火车查询、人品计算。。。

我实现了海南大学微信公众平台的部分功能,再根据自己需要另外添加了车牌查询等,这些功能觉得对我来说实用的,有下面几个:

1、ip/域名查询

2、车牌号归属地查询

3、手机归属地查询

4、公交查询

5、英汉互译

其中 ip查询是调用互联网的:http://www.ip.cn/getip.php?action=queryip&from=web&ip_url=

车牌号查询是我自己在网络上抓的数据import到mysql中,做的模糊like查询实现的

手机归属地查询也有现成的api可以调用:http://api.showji.com/Locating/www.showji.com.aspx?output=json&callback=querycallback&m=

公交查询是使用百度的私有api

英汉互译是调用百度的翻译api,需要申请一个key(code:keykey需要手动更改)

另外小i 因为经常被封杀的是使用cookies和js加密的,抱歉不能用表示我实在没有耐心和时间研究破解它了。

和上一篇blog所说的google tts也能够被调用,我并没有在截图中弄出来,因为还在测试中,暂时也没想到怎样应用它:

核心代码:

<?php//// 用經度, 緯度查詢 地址!// http://www.yuehn.com/tq.php?longitude=30.612270&latitude=104.067291// http://maps.googleapis.com/maps/api/geocode/json?latlng=30.612270,104.067291&sensor=false//// 參考資料..// https://developers.google.com/maps/documentation/geocoding/?hl=zh-twclass GoogleMapOBj
{function translateAddressToLatLng($address){$url = "http://maps.googleapis.com/maps/api/geocode/json?sensor=true&address=".urlencode($address);$request = file_get_contents($url);$json = json_decode($request,true);$geo_status = $json['status'];if($geo_status=="OVER_QUERY_LIMIT"){ die("OVER_QUERY_LIMIT"); }if($geo_status!="OK") return "return status error !";      //$geo_address = $json['results'][0]['formatted_address'];$geo_lat = $json['results'][0]['geometry']['location'];return $geo_lat;}    //
    public function translateLatLngtoAddress($lat,$long){$lat=mb_convert_encoding($lat, 'UTF-8',mb_detect_encoding($lat, 'UTF-8, ISO-8859-1', true));$long=mb_convert_encoding($long, 'UTF-8',mb_detect_encoding($long, 'UTF-8, ISO-8859-1', true));$url="http://maps.googleapis.com/maps/api/geocode/json?latlng=$lat,$long&sensor=false";$request=file_get_contents($url);$json=json_decode($request,true);return $json['results'][0]['formatted_address']; // 傳回此經緯度的地址//return $json['results'][0]['geometry']['location']; // 傳回經度與緯度
    }
}class BaiduTranslate
{function translateString($string){$url = "http://openapi.baidu.com/public/2.0/bmt/translate";$post_data = array('client_id' => 'keykey','q' => $string);$context = array();if (is_array($post_data)){ksort($post_data);$context['http'] = array('method' => 'POST','content' => http_build_query($post_data, '', '&'),);}$request = file_get_contents($url, false, stream_context_create($context));$json = json_decode($request,true);$trans_result = $json['trans_result'][0]['dst'];return $trans_result;}
}
class MobAddress
{function getMobAddressByNumber($number){$url = "http://api.showji.com/Locating/www.showji.com.aspx?output=json&callback=querycallback&m=".$number;$request = file_get_contents($url);$request = mb_substr($request, 14);$request = substr($request, 0, strlen($request)-2);$json1 = json_decode($request,true);if($json1['QueryResult'] == "True")$aaa=<<<STR
您查询的号码: {$json1['Mobile']}
卡号归属地: {$json1['Province']} {$json1['City']}
区号: {$json1['AreaCode']}
邮编: {$json1['PostCode']}
卡类型: {$json1['Corp']}{$json1['Card']}
STR;elsereturn "没有找到您要查询的手机号归属地";return $aaa;}
}
class IPAddress
{function getAddressByIP($ip){$url = "http://www.ip.cn/getip.php?action=queryip&from=web&ip_url=".$ip;$request = file_get_contents($url);$request = iconv("gbk","UTF-8",$request);return strip_tags($request);}
}
class Traff
{function getTraffLine($src,$dst){$url="http://map.baidu.com/?newmap=1&reqflag=pcmap&biz=1&qt=bt&c=1&sn=2$$$$$$".$src."$$0$$$$&en=2$$$$$$".$dst."$$0$$$$&sc=1&ec=1&rn=5&tn=B_NORMAL_MAP&nn=0&ie=utf-8&l=6&b=%289980316.235,2887022.065;14141852.235,3775854.065%29&t=1365849817463";$request = file_get_contents($url);//echo $request;$json = json_decode($request,true);//$trans_result = $json['content'][0]['lines'][0][0]['name'];$ReqStr = "";$planLines = array();$contents = $json['content'];foreach ($contents as $contentIndex => $contentValue){$lines = $contentValue['lines'];$stops = $contentValue['stops'];    //get stops$lineArr = array();$stopArr = array();for($num=0;$num<count($lines[0])-7;$num++){$tempArr = array();array_push($lineArr,$tempArr);}if(count($lines)<=0) return "请输入更精确的地址,如: 成都市武侯区武侯祠。";foreach ($lines as $lineIndex => $lineValue){$tools = $lineValue;//foreach ($tools as $toolIndex => $toolValue)for($toolIndex=0;$toolIndex<count($tools)-7;$toolIndex++){array_push($lineArr[$toolIndex],$this->getChunBus($tools[$toolIndex]['name']));$lineArr[$toolIndex] = array_unique($lineArr[$toolIndex]);}}foreach ($stops as $stopIndex => $stopValue){$stations = $stopValue;//foreach ($tools as $toolIndex => $toolValue)for($stationIndex=0;$stationIndex<count($stations);$stationIndex++){array_push($stopArr,$stations[$stationIndex]['getOff']['name']);array_push($stopArr,$stations[$stationIndex]['getOn']['name']);$stopArr = array_unique($stopArr);}}//$ReqStr .= print_r($lineArr).print_r($stopArr);array_push($planLines,Array('lines'=>$lineArr,'stops'=>$stopArr));}//echo print_r($planLines);foreach ($planLines as $planLineIndex => $planLineValue){$ReqStr .= (string)($planLineIndex+1).": ";$lines = $planLineValue['lines'];$stops = $planLineValue['stops'];foreach($lines as $lineIndex => $lineValue){$toolstr = "";if(count($lineValue)>=2)$toolstr = "(";foreach($lineValue as $tmpIndex => $tmpValue)    //[0] => 84路
                {$toolstr .= $tmpValue."/";}$toolstr = mb_substr($toolstr,0,mb_strlen($toolstr,"UTF-8")-1,"UTF-8");if(count($lineValue)>=2)$toolstr .= ")";$ReqStr .= $toolstr."→";}$ReqStr = mb_substr($ReqStr,0,mb_strlen($ReqStr,"UTF-8")-1,"UTF-8");$ReqStr .= "\n途经: ";$stops = array_slice($stops,1,count($stops)-2);foreach($stops as $stopIndex => $stopValue){$ReqStr .= $stopValue . ",";}$ReqStr = mb_substr($ReqStr,0,mb_strlen($ReqStr,"UTF-8")-1,"UTF-8");$ReqStr .= "\n";}return $ReqStr;}function getChunBus($Bus){return preg_replace('/\(.+?\)/','',$Bus);}
}class XiaoI
{public function get_wap_xiaoi($key){$post_data =array('requestContent='.$key,);$post_data = implode('&',$post_data);/***old method$url='http://nlp.xiaoi.com/robot/demo/wap/wap-demo.action';$ch = curl_init();curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_URL,$url);curl_setopt($ch,CURLOPT_USERAGENT,"Opera/9.60");curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);ob_start();curl_exec($ch);$result = ob_get_contents() ;ob_end_clean();*/$url="http://nlp.xiaoi.com/robot/demo/wap/";$ch = curl_init();  curl_setopt($ch, CURLOPT_URL, $url);  curl_setopt($ch, CURLOPT_HEADER, 1);  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  $content = curl_exec($ch);  curl_close($ch); //echo $content;list($header, $body) = explode("\r\n\r\n", $content);  preg_match("/set\-cookie:([^\r\n]*)/i", $header, $matches);  $cookie = $matches[1]; $ch = curl_init( ); curl_setopt( $ch, CURLOPT_REFERER, "http://nlp.xiaoi.com/robot/demo/wap/" ); curl_setopt( $ch, CURLOPT_HEADER, true ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6; Windows NT 5.0)" );  curl_setopt( $ch, CURLOPT_URL, "http://nlp.xiaoi.com/robot/demo/wap/wap-demo.action" ); curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_data );curl_setopt($ch, CURLOPT_COOKIE, $cookie);$content = curl_exec($ch);  curl_close($ch); $preg = '/<\/span>(.*)<\/p>/iUs';preg_match_all($preg,$content,$match);$response_msg=$match[0][0];$preg = "/<\/?[^>]+>/i";$response_msg=preg_replace($preg,'',$response_msg);if("hello,how are you"==$response_msg||"how do you do"==$response_msg){$response_msg="小i机器人欢迎您,欢迎各种调戏…/:,@-D";//欢迎语
       }$response_msg=trim($response_msg);return $response_msg;}
}class GoogleTTS
{public function getGoogleTTS($key,$tl='zh-cn'){$post_data =array('idx=0','ie=UTF-8','q='.$key,'tl='.$tl,'total=1','textlen='.(string)mb_strlen($key,"UTF-8"));$post_data = implode('&',$post_data);$url="http://translate.google.com/translate_tts";$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $url);curl_setopt( $ch, CURLOPT_REFERER, "http://translate.google.com" ); curl_setopt( $ch, CURLOPT_HEADER, true ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0" );  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: translate.google.com'));        //hostcurl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_data );$content = curl_exec($ch);curl_close($ch);$response_msg=trim($content);return $content;}
}?>

转载于:https://www.cnblogs.com/hyb1/archive/2013/05/08/3066913.html

微信公众平台功能大杂烩 - ip/域名查询 车牌号归属地查询 手机归属地查询 公交查询 英汉互译...相关推荐

  1. dedecms wxjk.php_织梦cms集成微信公众平台功能 织梦文章同步微信公众号就是这么简单...

    目前网上有很多这方面教程,关于dedecms微信插件,写的很详细,但是都是微信跳转的是PC网页,很难看,排版就乱了,今天南宫在这里介绍,如何跳转到dedecms织梦自带wap端,也就是跳到同内容的手机 ...

  2. uni-app 微信同声传译,实现AI语音功能(语音转文字,文字转语音,英汉互译

    uni-app 微信同声传译,实现AI语音功能(语音转文字,文字转语音,英汉互译) 一:添加插件 1.登录微信公众号平台,进入左边导航栏的设置,选择第三方设置,,添加插件,申请添加微信同声传译插件 2 ...

  3. 微信公众平台如何配置业务域名

    登陆微信公众平台首页 输入用户名和密码后,选择登陆 进入公众平台首页 在首页的左侧菜单中,找到 设置 选项 进入设置选项画面 在顶部的菜单中,找到开发设置 进入开发设置画面 在画面中就可以看到业务域名 ...

  4. 【云速建站】微信公众平台中维护IP白名单

    [摘要] 介绍获取接入IP白名单的操作步骤 网站后台对接微信公众号.支付等都依赖于白名单,接下来就介绍一下白名单的配置. 1.1      为什么要设置白名单 为了提高公众平台开发者接口调用的安全性, ...

  5. 关于微信公众平台本地测试ip如何加入IP白名单

    最近在搞微信公众平台这方面的东西,公司里用的是能配置微信公众平台的CMS,但实际使用的时候发现和access_token有关的接口都无法正常调用,于是debug了下,发现获取到了AppID和AppSe ...

  6. 用python设计一个简易的英汉互译界面_使用python一步一步搭建微信公众平台(二)----搭建一个中英互译的翻译工具...

    距离上次写使用python一步一步搭建微信公众平台(一)已经有几个月了,当中自已也搭建了一个中英文互译的小应用,可是由于英文翻中文好弄,中文翻译成英文一直有问题,知道是编码的问题,但是一直搞不定,于是 ...

  7. 微信公众平台-token验证失败(域名未备案导致替换方案)

    描述:我使用的是域名访问,但是我的域名并没有经过备案. URL:http://your_domain/{main.py url 映射路径}Token:随便写一个3-32位的字串 {要和handle.p ...

  8. 微信公众平台开发精彩花絮------文章来源:方倍工作室

    关键字:微信公众平台开发 作者:方倍工作室 在这篇微信公众平台开发教程中,我们假定你已经有了PHP语言程序.MySQL数据库.计算机网络通讯.及HTTP/XML/CSS/JS等基础. 我们将使用微信公 ...

  9. 微信公众平台开发入门教程(SAE方倍工作室)

    在这篇微信公众平台开发教程中,我们假定你已经有了PHP语言程序.MySQL数据库.计算机网络通讯.及HTTP/XML/CSS/JS等基础 我们将使用微信公众账号方倍工作室作为讲解的例子,二维码见底部. ...

最新文章

  1. HTML5新特性---Form表单前台通过正则表达式自动验证邮箱
  2. 【数字信号处理】线性常系数差分方程 ( 卷积 与 “ 线性常系数差分方程 “ | 使用 matlab 求解 “ 线性常系数差分方程 “ )
  3. php打开并填充表单,php – 创建一个’机器人’来填充带有一些页面的表单
  4. 用户生命周期管理,整体运营的基础与核心
  5. python openpyxl读写xlsx_python高阶教程-python操作xlsx文件(openpyxl)
  6. 百度网盘自动备份php,服务器自动备份脚本上传至百度云存储
  7. vlf 用法_什么是SQL虚拟日志文件(又名SQL Server VLF)?
  8. 《数据库系统概论》第一章笔记
  9. QTP自动化测试-点滴-步骤
  10. channelsftp实现两个xftp之间文件互传_基于Jsch实现Java操作linux服务器
  11. php mysql账号注册_php mysql用户注册登陆代码_PHP教程
  12. python 读xml_python读取xml文件
  13. 【PDF】PDF文件分页拆分(免费方法)
  14. 计算机网络第五版思维导图大全集
  15. Ubuntu安装客户端RabbitVCS(svn管理)
  16. matlab中mov是什么意思,PLC编程中MOV是什么意思
  17. 泛微OA流程自动汇总触发(流程触发集成)
  18. 水火箭的工作原理(化学反应)//2021-2-24 从群众中来,到群众中去
  19. isFinite() 如果参数是 NaN,正无穷大或者负无穷大,会返回 false,其他返回 true
  20. matlab绘制心形图

热门文章

  1. 【报告分享】Z世代美颜消费趋势报告-CBNData(附下载)
  2. 紫外可见分光光度计种类的优缺点?
  3. python开发实训平台_一体化教学实训平台解决方案
  4. git push 总是报错 Push rejected: Push to origin/dev was rejected
  5. linux驱动篇-button-int-poll
  6. 优秀课件笔记旅游资源和旅游地评价 Evaluation of Tourism Resources 4
  7. 矩阵按键(按下按键S1到S16,数码管显示0到F)
  8. 电脑报2008年合订本
  9. 洗脚城的管理模式:代理模式
  10. 游戏3C之三——操作