微信公众平台开发尝试,微信公众平台
最近看了一篇博文是说微信公众平台搭建,于是心血来潮自己也尝试了一下。
1.不用多讲了,申请微信公众号,对于个人来说,只能申请订阅号。
可以看这个链接的文章,http://jingyan.baidu.com/article/414eccf6011ff06b431f0aec.html
2.采用的是Sina App Engine来脱管服务,就要申请sae开发者权限。
再看这个链接http://jingyan.baidu.com/article/4f7d57129a60531a20192796.html
3.在sae上新建一个应用
我选择的PHP,PHP几乎免费。Java应用的话,有点小贵了。
虽然没有学过PHP,摸着石头过河吧。
将php代码上传后,就有一个可调试的url了,PHP代码后面上。
4.再在微信公众平台中的开发者中心(这个要经过一段时间的审核),填入一下内容即可
5.然后就是对接数据了,为了测试,我对接的是图灵机器人的数据、12306和百度地图API
12306是为了查余票和车次,百度地图API是为了查天气预报、图灵机器人见链接:http://www.tuling123.com/openapi/
php代码如下,本人不是搞PHP的,因此只能在网上拷贝了,如有复制,纯属巧合。
php
define("TOKEN", "weixin"
);
Session_start();
Session_Register("kw"
);
$wechatObj =
new wechatCallbackapiTest();
require_once("train.php"
);
$tqTpl = "
%s 5 -
-
-
-
-
-
"
;
if (!
isset(
$_GET['echostr'
])) {
$wechatObj->
responseMsg();
}else{
$wechatObj->
valid();
}
class wechatCallbackapiTest
{
//验证签名
public function valid()
{
$echoStr =
$_GET["echostr"
];
$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){
echo $echoStr;
exit;
}
}
//响应消息
public function responseMsg()
{
$postStr =
$GLOBALS["HTTP_RAW_POST_DATA"
];
if (!
empty(
$postStr)){
$this->logger("R ".
$postStr);
$postObj =
simplexml_load_string(
$postStr, 'SimpleXMLElement',
LIBXML_NOCDATA);
$RX_TYPE =
trim(
$postObj->
MsgType);
//消息类型分离
switch (
$RX_TYPE)
{
case "event":
$result =
$this->receiveEvent(
$postObj);
break;
case "text":
$result =
$this->receiveTulingText(
$postObj);
break;
case "image":
$result =
$this->receiveImage(
$postObj);
break;
case "location":
$result =
$this->receiveLocation(
$postObj);
break;
case "voice":
$result =
$this->receiveVoice(
$postObj);
break;
case "video":
$result =
$this->receiveVideo(
$postObj);
break;
case "link":
$result =
$this->receiveLink(
$postObj);
break;
default:
$result = "unknown msg type: ".
$RX_TYPE;
break;
}
$this->logger("T ".
$result);
echo $result;
}else {
echo ""
;
exit;
}
}
//接收事件消息
private function receiveEvent(
$object)
{
$content = ""
;
switch (
$object->
Event)
{
case "subscribe":
$content = "欢迎关注TomSnail "
;
$content .= (!
empty(
$object->EventKey))?("\n来自二维码场景 ".
str_replace("qrscene_","",
$object->EventKey)):""
;
break;
case "unsubscribe":
$content = "取消关注"
;
break;
case "SCAN":
$content = "扫描场景 ".
$object->
EventKey;
break;
case "CLICK":
switch (
$object->
EventKey)
{
case "COMPANY":
$content =
array();
$content[] =
array("Title"=>"多图文1标题", "Description"=>"", "PicUrl"=>"http://discuz.comli.com/weixin/weather/icon/cartoon.jpg", "Url" =>"http://m.cnblogs.com/?u=txw1958"
);
break;
default:
$content = "点击菜单:".
$object->
EventKey;
break;
}
break;
case "LOCATION":
$content = "上传位置:纬度 ".
$object->Latitude.";经度 ".
$object->
Longitude;
break;
case "VIEW":
$content = "跳转链接 ".
$object->
EventKey;
break;
case "MASSSENDJOBFINISH":
$content = "消息ID:".
$object->MsgID.",结果:".
$object->Status.",粉丝数:".
$object->TotalCount.",过滤:".
$object->FilterCount.",发送成功:".
$object->SentCount.",发送失败:".
$object->
ErrorCount;
break;
default:
$content = "receive a new event: ".
$object->
Event;
break;
}
if(
is_array(
$content)){
if (
isset(
$content[0
])){
$result =
$this->transmitNews(
$object,
$content);
}else if (
isset(
$content['MusicUrl'
])){
$result =
$this->transmitMusic(
$object,
$content);
}
}else{
$result =
$this->transmitText(
$object,
$content);
}
return $result;
}
private function receiveTulingText(
$object){
try{
$keyword =
trim(
$object->
Content);
$userid =
trim(
$object->
FromUserName);
$apiKey = "*******************************"
;
$apiURL = "http://www.tuling123.com/openapi/api?key=".
$apiKey."&info=".
$keyword."&userid=".
userid;
if((
substr_count(
$keyword,'天气')!=0)||
$_SESSION["kw"]=="天气"){
//百度地图API
if(
$keyword=="天气"
){
$_SESSION["kw"]="天气"
;
$content = "请输入城市".
$_SESSION["kw"
];
}else{
$geshu =
substr_count(
$keyword,'天气'
);
if(
$geshu==0
){
$city =
$keyword;
}else{
$t =
explode("天气",
$keyword);
for(
$i=0;
$i<=
$geshu;
$i++
)
{
if(
$t[
$i]!=''
)
{
$city =
$t[
$i];
break;
}
}
}
$mykey ="*********************"
;
$url = "http://api.map.baidu.com/telematics/v3/weather?location=".
$city."&output=json&ak=".
$mykey;
$output =
file_get_contents(
$url);
$contentStr = json_decode(
$output,
true);
if(
$contentStr['status']=='success'
)
{
$T[0]['Title']=
$contentStr['date']." ".
$contentStr['results'][0]['currentCity']."天气"
;
$T[0]['PicUrl']="http://zhengwairen-try2.stor.sinaapp.com/xytq.jpg"
;
$T[0]['Url']="http://zhengwairen-try2.stor.sinaapp.com/xytq.jpg"
;
if(
is_array(
$contentStr['results'][0]['index'
]))
{
$T[2]['Title']="【pm2.5】".
$contentStr['results'][0]['pm25']."\n"."【".
$contentStr['results'][0]['index'][0]['title']."】"."(".
$contentStr['results'][0]['index'][0]['zs'].") ".
$contentStr['results'][0]['index'][0]['des'
];
//下一行是洗车指数,感觉不对主题还是不要的好。。 //$T[2]['Title']=$T[2]['Title']."\n"."【".$contentStr['results'][0]['index'][1]['title']."】(".$contentStr['results'][0]['index'][1]['zs'].")".$contentStr['results'][0]['index'][1]['des'];
$T[2]['Title']=
$T[2]['Title']."\n"."【".
$contentStr['results'][0]['index'][2]['title']."】(".
$contentStr['results'][0]['index'][2]['zs'].")".
$contentStr['results'][0]['index'][2]['des'
];
}
else
$guowai=1
;
for(
$i=1,
$aaa=0;
$i<=5;
$i++
)
{
if(
$i==2 &&
$guowai!=1
)
continue;
if(
$guowai==1 &&
$i==5
)
continue;
$T[
$i]['Title']=
$contentStr['results'][0]['weather_data'][
$aaa]['date']."".
$contentStr['results'][0]['weather_data'][
$aaa]['temperature']."".
$contentStr['results'][0]['weather_data'][
$aaa]['weather']." ".
$contentStr['results'][0]['weather_data'][
$aaa]['wind'
];
$T[
$i]['PicUrl']=
$contentStr['results'][0]['weather_data'][
$aaa]['dayPictureUrl'
];
$T[
$i]['Url']=
$contentStr['results'][0]['weather_data'][
$aaa]['dayPictureUrl'
];
$aaa++
;
}
$content =
$T;
}
}
}else if(
substr_count(
$keyword,'火车')!=0 &&
$keyword!='火车'){
//12306
$geshu =
substr_count(
$keyword,'火车:'
);
$k =
str_replace('火车 ', "",
$keyword);
$t =
explode(" ",
$k);
$startstaion =
$t[0
];
$endstation =
$t[1
];
$date =
$t[2
];
if(
$date==
null){
$date =
date("Y-m-d",
time());
}
if(
substr_count(
$date,'-')==0
){
$date =
date("Y-m",
time())."-".
$date;
}
$time =
$t[3
];
if(
$time==
null){
$time = "00:00"
;
}
if(
substr_count(
$time,':')==0
){
$time =
$time.":00"
;
}
$data = gettrain(
$startstaion,
$endstation,
$date,
$time);
$str=""
;
$T[0]['Title']=
$startstaion."到".
$endstation." ".
$date." ".
$time."以后10列火车信息"
;
$T[0]['PicUrl']="http://zhengwairen-try2.stor.sinaapp.com/xytq.jpg"
;
$T[0]['Url']="http://zhengwairen-try2.stor.sinaapp.com/xytq.jpg"
;
$count = 1
;
foreach(
$data as $key =>
$value){
$str=
$count." "
;
$str.="火车列次:{
$data[
$key]['station_train_code']}\n"
;
$str.="始发站:{
$data[
$key]['start_station_name']},终点站:{
$data[
$key]['end_station_name']}\n"
;
$str.="出发时间:{
$data[
$key]['start_time']},到站时间:{
$data[
$key]['arrive_time']},历时:{
$data[
$key]['lishi']}\n"
;
$str.="一等座:{
$data[
$key]['zy_num']}\n二等座:{
$data[
$key]['ze_num']}\n硬座:{
$data[
$key]['yz_num']}\n硬卧:{
$data[
$key]['yw_num']}\n"
;
$str.="软卧:{
$data[
$key]['rw_num']}\n软座:{
$data[
$key]['rz_num']}\n特等座:{
$data[
$key]['tz_num']}\n无座:{
$data[
$key]['wz_num']}"
;
$count =
$count+1
;
$T[
$count]['Title'] =
$str;
// $T[$count]['Url']="http://kyfw.12306.cn/otn/leftTicket/queryTicketPrice?train_no=".$data[$key]["train_no"]."&from_station_no=".$data[$key]["from_station_no"]."&to_station_no=".$data[$key]["to_station_no"]."&seat_types=".$data[$key]["seat_types"]."&train_date=$date";
$T[
$count]['Url'] = "https://kyfw.12306.cn/otn/login/init"
;
if(
$count==10
){
break;}
}
$content =
$T;
}else{
//图灵机器人
$file_contents =
file_get_contents(
$apiURL);
$file_contents = json_decode(
$file_contents,
true);
$code =
$file_contents["code"
];
if(
$code==100000
){
$content =
$file_contents["text"
];
}else if(
$code==200000
){
$T[0]['Title']=
$file_contents["text"
];
//$T[0]['PicUrl']="http://zhengwairen-try2.stor.sinaapp.com/xytq.jpg";
$T[0]['Url']=
$file_contents["url"
];
$content =
$T;
}else if(
$code==302000
){
$T[0]['Title']=
$file_contents["text"
];
$T[0]['PicUrl']="http://zhengwairen-try2.stor.sinaapp.com/xytq.jpg"
;
$T[0]['Url']="http://zhengwairen-try2.stor.sinaapp.com/xytq.jpg"
;
$data =
$file_contents["list"
];
$count = 1
;
foreach(
$data as $key =>
$value){
$T[
$count]['Title']=
$data[
$key]["article"
];
$T[
$count]['PicUrl']=
$data[
$key]["icon"
];
$T[
$count]['Url']=
$data[
$key]["detailurl"
];
$count++
;
}
$content =
$T;
}else if(
$code==305000
){
$T[0]['Title']=
$file_contents["text"
];
$T[0]['PicUrl']="http://zhengwairen-try2.stor.sinaapp.com/xytq.jpg"
;
$T[0]['Url']="http://zhengwairen-try2.stor.sinaapp.com/xytq.jpg"
;
$data =
$file_contents["list"
];
$count = 1
;
foreach(
$data as $key =>
$value){
$T[
$count]['Title']="车次".
$data[
$key]["trainnum"]."\n起始站:".
$data[
$key]["start"]."\n到达站:".
$data[
$key]["terminal"]."\n开车时间:".
$data[
$key]["starttime"]."\n到达时间:".
$data[
$key]["endtime"
];
$T[
$count]['PicUrl']=
$data[
$key]["icon"
];
$T[
$count]['Url']=
$data[
$key]["detailurl"
];
$count++
;
if(
$count==10
){
break;
}
}
$content =
$T;
}else if(
$code==306000
){
$T[0]['Title']=
$file_contents["text"
];
$T[0]['PicUrl']="http://zhengwairen-try2.stor.sinaapp.com/xytq.jpg"
;
$T[0]['Url']="http://zhengwairen-try2.stor.sinaapp.com/xytq.jpg"
;
$data =
$file_contents["list"
];
$count = 1
;
foreach(
$data as $key =>
$value){
$T[
$count]['Title']="航班号".
$data[
$key]["flight"]."航班路线".
$data[
$key]["route"]."\n起飞时间:".
$data[
$key]["starttime"]."\n到达时间:".
$data[
$key]["endtime"]."\n状态:".
$data[
$key]["state"
];
$T[
$count]['PicUrl']=
$data[
$key]["icon"
];
$T[
$count]['Url']=
$data[
$key]["detailurl"
];
$count++
;
}
$content =
$T;
}else if(
$code==308000
){
$T[0]['Title']=
$file_contents["text"
];
$T[0]['PicUrl']="http://zhengwairen-try2.stor.sinaapp.com/xytq.jpg"
;
$T[0]['Url']="http://zhengwairen-try2.stor.sinaapp.com/xytq.jpg"
;
$data =
$file_contents["list"
];
$count = 1
;
foreach(
$data as $key =>
$value){
$T[
$count]['Title']="名称".
$data[
$key]["name"]."详情".
$data[
$key]["info"
];
$T[
$count]['PicUrl']=
$data[
$key]["icon"
];
$T[
$count]['Url']=
$data[
$key]["detailurl"
];
$count++
;
}
$content =
$T;
}else{
$content =
$file_contents["text"
];
}
}
if(
is_array(
$content)){
if (
isset(
$content[0]['PicUrl'
])){
$result =
$this->transmitNews(
$object,
$content);
}else if (
isset(
$content['MusicUrl'
])){
$result =
$this->transmitMusic(
$object,
$content);
}
}else{
$result =
$this->transmitText(
$object,
$content);
}
}catch(
Exception $e){
$content=
$e->
getMessage();
$result =
$this->transmitText(
$object,
$content);
}
return $result;
}
//接收图片消息
private function receiveImage(
$object)
{
$content =
array("MediaId"=>
$object->
MediaId);
$result =
$this->transmitImage(
$object,
$content);
return $result;
}
//接收位置消息
private function receiveLocation(
$object)
{
$content = "你发送的是位置,纬度为:".
$object->Location_X.";经度为:".
$object->Location_Y.";缩放级别为:".
$object->Scale.";位置为:".
$object->
Label;
$result =
$this->transmitText(
$object,
$content);
return $result;
}
//接收语音消息
private function receiveVoice(
$object)
{
if (
isset(
$object->Recognition) && !
empty(
$object->
Recognition)){
$content = "你刚才说的是:".
$object->
Recognition;
$result =
$this->transmitText(
$object,
$content);
}else{
$content =
array("MediaId"=>
$object->
MediaId);
$result =
$this->transmitVoice(
$object,
$content);
}
return $result;
}
//接收视频消息
private function receiveVideo(
$object)
{
$content =
array("MediaId"=>
$object->MediaId, "ThumbMediaId"=>
$object->ThumbMediaId, "Title"=>"", "Description"=>""
);
$result =
$this->transmitVideo(
$object,
$content);
return $result;
}
//接收链接消息
private function receiveLink(
$object)
{
$content = "你发送的是链接,标题为:".
$object->Title.";内容为:".
$object->Description.";链接地址为:".
$object->
Url;
$result =
$this->transmitText(
$object,
$content);
return $result;
}
//回复文本消息
private function transmitText(
$object,
$content)
{
$xmlTpl = "
%s
"
;
$result =
sprintf(
$xmlTpl,
$object->FromUserName,
$object->ToUserName,
time(),
$content);
return $result;
}
//回复图片消息
private function transmitImage(
$object,
$imageArray)
{
$itemTpl = "
"
;
$item_str =
sprintf(
$itemTpl,
$imageArray['MediaId'
]);
$xmlTpl = "
%s
$item_str
"
;
$result =
sprintf(
$xmlTpl,
$object->FromUserName,
$object->ToUserName,
time());
return $result;
}
//回复语音消息
private function transmitVoice(
$object,
$voiceArray)
{
$itemTpl = "
"
;
$item_str =
sprintf(
$itemTpl,
$voiceArray['MediaId'
]);
$xmlTpl = "
%s
$item_str
"
;
$result =
sprintf(
$xmlTpl,
$object->FromUserName,
$object->ToUserName,
time());
return $result;
}
//回复视频消息
private function transmitVideo(
$object,
$videoArray)
{
$itemTpl = "
"
;
$item_str =
sprintf(
$itemTpl,
$videoArray['MediaId'],
$videoArray['ThumbMediaId'],
$videoArray['Title'],
$videoArray['Description'
]);
$xmlTpl = "
%s
$item_str
"
;
$result =
sprintf(
$xmlTpl,
$object->FromUserName,
$object->ToUserName,
time());
return $result;
}
//回复图文消息
private function transmitNews(
$object,
$newsArray)
{
if(!
is_array(
$newsArray)){
return;
}
$itemTpl = "
-
"
;
$item_str = ""
;
foreach (
$newsArray as $item){
$item_str .=
sprintf(
$itemTpl,
$item['Title'],
$item['Description'],
$item['PicUrl'],
$item['Url'
]);
}
$xmlTpl = "
%s
%s
$item_str
"
;
$result =
sprintf(
$xmlTpl,
$object->FromUserName,
$object->ToUserName,
time(),
count(
$newsArray));
return $result;
}
//回复音乐消息
private function transmitMusic(
$object,
$musicArray)
{
$itemTpl = "
"
;
$item_str =
sprintf(
$itemTpl,
$musicArray['Title'],
$musicArray['Description'],
$musicArray['MusicUrl'],
$musicArray['HQMusicUrl'
]);
$xmlTpl = "
%s
$item_str
"
;
$result =
sprintf(
$xmlTpl,
$object->FromUserName,
$object->ToUserName,
time());
return $result;
}
//回复多客服消息
private function transmitService(
$object)
{
$xmlTpl = "
%s
"
;
$result =
sprintf(
$xmlTpl,
$object->FromUserName,
$object->ToUserName,
time());
return $result;
}
//日志记录
private function logger(
$log_content)
{
if(
isset(
$_SERVER['HTTP_APPNAME'])){
//SAE
sae_set_display_errors(
false);
sae_debug($log_content);
sae_set_display_errors(true);
}else if(
$_SERVER['REMOTE_ADDR'] != "127.0.0.1"){
//LOCAL
$max_size = 10000
;
$log_filename = "log.xml"
;
if(
file_exists(
$log_filename) and (
abs(
filesize(
$log_filename)) >
$max_size)){
unlink(
$log_filename);}
file_put_contents(
$log_filename,
date('H:i:s')." ".
$log_content."\r\n",
FILE_APPEND);
}
}
}
?>
View Code
php
return array(
"北京北" => "VAP",
"北京东" => "BOP",
"北京" => "BJP",
"北京南" => "VNP",
"北京西" => "BXP",
"重庆北" => "CUW",
"重庆" => "CQW",
"重庆南" => "CRW",
"长春" => "CCT",
"长春南" => "CET",
"长春西" => "CRT",
"成都东" => "ICW",
"成都南" => "CNW",
"成都" => "CDW",
"长沙" => "CSQ",
"长沙南" => "CWQ",
"阿尔山" => "ART",
"安康" => "AKY",
"阿克苏" => "ASR",
"阿里河" => "AHX",
"阿拉山口" => "AKR",
"安平" => "APT",
"安庆" => "AQH",
"安顺" => "ASW",
"鞍山" => "AST",
"安阳" => "AYF",
"北安" => "BAB",
"蚌埠" => "BBH",
"白城" => "BCT",
"北海" => "BHZ",
"白河" => "BEL",
"白涧" => "BAP",
"宝鸡" => "BJY",
"滨江" => "BJB",
"博克图" => "BKX",
"百色" => "BIZ",
"白山市" => "HJL",
"北台" => "BTT",
"包头东" => "BDC",
"包头" => "BTC",
"北屯市" => "BXR",
"本溪" => "BXT",
"白云鄂博" => "BEC",
"白银西" => "BXJ",
"亳州" => "BZH",
"赤壁" => "CBN",
"常德" => "VGQ",
"承德" => "CDP",
"长甸" => "CDT",
"赤峰" => "CFD",
"茶陵" => "CDG",
"苍南" => "CEH",
"昌平" => "CPP",
"崇仁" => "CRG",
"昌图" => "CTT",
"长汀镇" => "CDB",
"崇信" => "CIJ",
"曹县" => "CXK",
"楚雄" => "COM",
"陈相屯" => "CXT",
"长治北" => "CBF",
"长征" => "CZJ",
"池州" => "IYH",
"常州" => "CZH",
"郴州" => "CZQ",
"长治" => "CZF",
"沧州" => "COP",
"崇左" => "CZZ",
"大安北" => "RNT",
"大成" => "DCT",
"丹东" => "DUT",
"东方红" => "DFB",
"东莞东" => "DMQ",
"大虎山" => "DHD",
"敦煌" => "DHJ",
"敦化" => "DHL",
"德惠" => "DHT",
"东京城" => "DJB",
"大涧" => "DFP",
"都江堰" => "DDW",
"大连北" => "DFT",
"大理" => "DKM",
"大连" => "DLT",
"定南" => "DNG",
"大庆" => "DZX",
"东胜" => "DOC",
"大石桥" => "DQT",
"大同" => "DTV",
"东营" => "DPK",
"大杨树" => "DUX",
"都匀" => "RYW",
"邓州" => "DOF",
"达州" => "RXW",
"德州" => "DZP",
"额济纳" => "EJC",
"二连" => "RLC",
"恩施" => "ESN",
"昂昂溪" => "AAX",
"阿城" => "ACB",
"安达" => "ADX",
"安定" => "ADP",
"安广" => "AGT",
"艾河" => "AHP",
"安化" => "PKQ",
"艾家村" => "AJJ",
"鳌江" => "ARH",
"安家" => "AJB",
"阿金" => "AJD",
"阿克陶" => "AER",
"安口窑" => "AYY",
"敖力布告" => "ALD",
"安龙" => "AUZ",
"阿龙山" => "ASX",
"安陆" => "ALN",
"阿木尔" => "JTX",
"阿南庄" => "AZM",
"安庆西" => "APH",
"鞍山西" => "AXT",
"安塘" => "ATV",
"安亭北" => "ASH",
"阿图什" => "ATR",
"安图" => "ATL",
"安溪" => "AXS",
"博鳌" => "BWQ",
"白壁关" => "BGV",
"蚌埠南" => "BMH",
"巴楚" => "BCR",
"板城" => "BUP",
"北戴河" => "BEP",
"保定" => "BDP",
"宝坻" => "BPP",
"八达岭" => "ILP",
"巴东" => "BNN",
"柏果" => "BGM",
"布海" => "BUT",
"白河东" => "BIY",
"贲红" => "BVC",
"宝华山" => "BWH",
"白河县" => "BEY",
"白芨沟" => "BJJ",
"碧鸡关" => "BJM",
"北滘" => "IBQ",
"碧江" => "BLQ",
"白鸡坡" => "BBM",
"笔架山" => "BSB",
"八角台" => "BTD",
"保康" => "BKD",
"白奎堡" => "BKB",
"白狼" => "BAT",
"百浪" => "BRZ",
"博乐" => "BOR",
"宝拉格" => "BQC",
"巴林" => "BLX",
"宝林" => "BNB",
"北流" => "BOZ",
"勃利" => "BLB",
"布列开" => "BLR",
"宝龙山" => "BND",
"八面城" => "BMD",
"班猫箐" => "BNM",
"八面通" => "BMB",
"北马圈子" => "BRP",
"北票南" => "RPD",
"白旗" => "BQP",
"宝泉岭" => "BQB",
"白泉" => "BQL",
"白沙" => "BSW",
"巴山" => "BAY",
"白水江" => "BSY",
"白沙坡" => "BPM",
"白石山" => "BAL",
"白水镇" => "BUM",
"坂田" => "BTQ",
"泊头" => "BZP",
"北屯" => "BYP",
"本溪湖" => "BHT",
"博兴" => "BXK",
"八仙筒" => "VXD",
"白音察干" => "BYC",
"背荫河" => "BYB",
"北营" => "BIV",
"巴彦高勒" => "BAC",
"白音他拉" => "BID",
"鲅鱼圈" => "BYT",
"白银市" => "BNJ",
"白音胡硕" => "BCD",
"巴中" => "IEW",
"霸州" => "RMP",
"北宅" => "BVP",
"赤壁北" => "CIN",
"查布嘎" => "CBC",
"长城" => "CEJ",
"长冲" => "CCM",
"承德东" => "CCP",
"赤峰西" => "CID",
"嵯岗" => "CAX",
"柴岗" => "CGT",
"长葛" => "CEF",
"柴沟堡" => "CGV",
"城固" => "CGY",
"陈官营" => "CAJ",
"成高子" => "CZB",
"草海" => "WBW",
"柴河" => "CHB",
"册亨" => "CHZ",
"草河口" => "CKT",
"崔黄口" => "CHP",
"巢湖" => "CIH",
"蔡家沟" => "CJT",
"成吉思汗" => "CJX",
"岔江" => "CAM",
"蔡家坡" => "CJY",
"沧口" => "CKK",
"昌乐" => "CLK",
"超梁沟" => "CYP",
"慈利" => "CUQ",
"昌黎" => "CLP",
"长岭子" => "CLT",
"晨明" => "CMB",
"长农" => "CNJ",
"昌平北" => "VBP",
"长坡岭" => "CPM",
"辰清" => "CQB",
"楚山" => "CSB",
"长寿" => "EFW",
"磁山" => "CSP",
"苍石" => "CST",
"草市" => "CSL",
"察素齐" => "CSC",
"长山屯" => "CVT",
"长汀" => "CES",
"昌图西" => "CPT",
"春湾" => "CQQ",
"磁县" => "CIP",
"岑溪" => "CNZ",
"辰溪" => "CXQ",
"磁西" => "CRP",
"长兴南" => "CFH",
"磁窑" => "CYK",
"朝阳" => "CYD",
"春阳" => "CAL",
"城阳" => "CEK",
"创业村" => "CEX",
"朝阳川" => "CYL",
"朝阳地" => "CDD",
"长垣" => "CYF",
"朝阳镇" => "CZL",
"滁州北" => "CUH",
"常州北" => "ESH",
"滁州" => "CXH",
"潮州" => "CKQ",
"常庄" => "CVK",
"曹子里" => "CFP",
"车转湾" => "CWM",
"郴州西" => "ICQ",
"沧州西" => "CBP",
"德安" => "DAG",
"大安" => "RAT",
"东安" => "DAZ",
"大坝" => "DBJ",
"大板" => "DBC",
"大巴" => "DBD",
"到保" => "RBT",
"定边" => "DYJ",
"东边井" => "DBB",
"德伯斯" => "RDT",
"打柴沟" => "DGJ",
"德昌" => "DVW",
"滴道" => "DDB",
"大德" => "DEM",
"大磴沟" => "DKJ",
"刀尔登" => "DRD",
"得耳布尔" => "DRX",
"东方" => "UFQ",
"丹凤" => "DGY",
"东丰" => "DIL",
"都格" => "DMM",
"大官屯" => "DTT",
"大关" => "RGW",
"东光" => "DGP",
"东莞" => "DAQ",
"东海" => "DHB",
"大灰厂" => "DHP",
"大红旗" => "DQD",
"东海县" => "DQH",
"德惠西" => "DXT",
"达家沟" => "DJT",
"东津" => "DKB",
"杜家" => "DJL",
"大旧庄" => "DJM",
"大口屯" => "DKP",
"东来" => "RVD",
"德令哈" => "DHO",
"大陆号" => "DLC",
"带岭" => "DLB",
"大林" => "DLD",
"达拉特旗" => "DIC",
"独立屯" => "DTX",
"豆罗" => "DLV",
"达拉特西" => "DNC",
"东明村" => "DMD",
"洞庙河" => "DEP",
"东明县" => "DNF",
"大拟" => "DNZ",
"大平房" => "DPD",
"大盘石" => "RPP",
"大埔" => "DPI",
"大堡" => "DVT",
"大其拉哈" => "DQX",
"道清" => "DML",
"对青山" => "DQB",
"德清西" => "MOH",
"东升" => "DRQ",
"独山" => "RWW",
"砀山" => "DKH",
"登沙河" => "DWT",
"读书铺" => "DPM",
"大石头" => "DSL",
"大石寨" => "RZT",
"东台" => "DBH",
"定陶" => "DQK",
"灯塔" => "DGT",
"大田边" => "DBM",
"东通化" => "DTL",
"丹徒" => "RUH",
"大屯" => "DNT",
"东湾" => "DRJ",
"大武口" => "DFJ",
"低窝铺" => "DWJ",
"大王滩" => "DZZ",
"大湾子" => "DFM",
"大兴沟" => "DXL",
"大兴" => "DXX",
"定西" => "DSJ",
"甸心" => "DXM",
"东乡" => "DXG",
"代县" => "DKV",
"定襄" => "DXV",
"东戌" => "RXP",
"东辛庄" => "DXD",
"丹阳" => "DYH",
"大雁" => "DYX",
"德阳" => "DYW",
"当阳" => "DYN",
"丹阳北" => "EXH",
"大英东" => "IAW",
"东淤地" => "DBV",
"大营" => "DYV",
"定远" => "EWH",
"岱岳" => "RYV",
"大元" => "DYZ",
"大营镇" => "DJP",
"大营子" => "DZD",
"大战场" => "DTJ",
"德州东" => "DIP",
"低庄" => "DVQ",
"东镇" => "DNV",
"道州" => "DFZ",
"东至" => "DCH",
"东庄" => "DZV",
"兑镇" => "DWV",
"豆庄" => "ROP",
"定州" => "DXP",
"大竹园" => "DZY",
"大杖子" => "DAP",
"豆张庄" => "RZP",
"峨边" => "EBW",
"二道沟门" => "RDP",
"二道湾" => "RDX",
"二龙" => "RLD",
"二龙山屯" => "ELA",
"峨眉" => "EMW",
"二密河" => "RML",
"二营" => "RYJ",
"鄂州" => "ECN",
"安阳东" => "ADF",
"保定东" => "BMP",
"长阳" => "CYN",
"东二道河" => "DRB",
"大苴" => "DIM",
"大青沟" => "DSD",
"定州东" => "DOP",
"福州" => "FZS",
"福州南" => "FYS",
"贵阳" => "GIW",
"广州北" => "GBQ",
"广州东" => "GGQ",
"广州" => "GZQ",
"广州南" => "IZQ",
"哈尔滨" => "HBB",
"哈尔滨东" => "VBB",
"哈尔滨西" => "VAB",
"合肥" => "HFH",
"合肥西" => "HTH",
"呼和浩特东" => "NDC",
"呼和浩特" => "HHC",
"海口东" => "HMQ",
"海口" => "VUQ",
"杭州" => "HZH",
"杭州南" => "XHH",
"济南" => "JNK",
"济南东" => "JAK",
"济南西" => "JGK",
"防城港" => "FEZ",
"福鼎" => "FES",
"风陵渡" => "FLV",
"涪陵" => "FLW",
"富拉尔基" => "FRX",
"抚顺北" => "FET",
"佛山" => "FSQ",
"阜新" => "FXD",
"阜阳" => "FYH",
"格尔木" => "GRO",
"广汉" => "GHW",
"古交" => "GJV",
"桂林北" => "GBZ",
"古莲" => "GRX",
"桂林" => "GLZ",
"固始" => "GXN",
"广水" => "GSN",
"干塘" => "GNJ",
"广元" => "GYW",
"赣州" => "GZG",
"公主岭" => "GLT",
"公主岭南" => "GBT",
"淮安" => "AUH",
"鹤北" => "HMB",
"淮北" => "HRH",
"淮滨" => "HVN",
"河边" => "HBV",
"潢川" => "KCN",
"韩城" => "HCY",
"邯郸" => "HDP",
"横道河子" => "HDB",
"鹤岗" => "HGB",
"皇姑屯" => "HTT",
"红果" => "HEM",
"黑河" => "HJB",
"怀化" => "HHQ",
"汉口" => "HKN",
"葫芦岛" => "HLD",
"海拉尔" => "HRX",
"霍林郭勒" => "HWD",
"海伦" => "HLB",
"侯马" => "HMV",
"哈密" => "HMR",
"淮南" => "HAH",
"桦南" => "HNB",
"海宁西" => "EUH",
"鹤庆" => "HQM",
"怀柔北" => "HBP",
"怀柔" => "HRP",
"黄石东" => "OSN",
"华山" => "HSY",
"黄石" => "HSN",
"黄山" => "HKH",
"衡水" => "HSP",
"衡阳" => "HYQ",
"菏泽" => "HIK",
"贺州" => "HXZ",
"汉中" => "HOY",
"惠州" => "HCQ",
"吉安" => "VAG",
"集安" => "JAL",
"江边村" => "JBG",
"晋城" => "JCF",
"金城江" => "JJZ",
"景德镇" => "JCG",
"嘉峰" => "JFF",
"加格达奇" => "JGX",
"井冈山" => "JGG",
"蛟河" => "JHL",
"金华南" => "RNH",
"金华西" => "JBH",
"九江" => "JJG",
"吉林" => "JLL",
"荆门" => "JMN",
"佳木斯" => "JMB",
"济宁" => "JIK",
"集宁南" => "JAC",
"酒泉" => "JQJ",
"江山" => "JUH",
"吉首" => "JIQ",
"九台" => "JTL",
"镜铁山" => "JVJ",
"鸡西" => "JXB",
"蓟县" => "JKP",
"绩溪县" => "JRH",
"嘉峪关" => "JGJ",
"江油" => "JFW",
"锦州" => "JZD",
"金州" => "JZT",
"福安" => "FAS",
"防城" => "FAZ",
"丰城" => "FCG",
"丰城南" => "FNG",
"肥东" => "FIH",
"发耳" => "FEM",
"富海" => "FHX",
"福海" => "FHR",
"凤凰城" => "FHT",
"奉化" => "FHH",
"富锦" => "FIB",
"范家屯" => "FTT",
"福利屯" => "FTB",
"丰乐镇" => "FZB",
"阜南" => "FNH",
"阜宁" => "AKH",
"抚宁" => "FNP",
"福清" => "FQS",
"福泉" => "VMW",
"丰水村" => "FSJ",
"丰顺" => "FUQ",
"繁峙" => "FSV",
"抚顺" => "FST",
"福山口" => "FKP",
"扶绥" => "FSZ",
"冯屯" => "FTX",
"浮图峪" => "FYP",
"富县东" => "FDY",
"凤县" => "FXY",
"富县" => "FEY",
"费县" => "FXK",
"凤阳" => "FUH",
"汾阳" => "FAV",
"扶余北" => "FBT",
"分宜" => "FYG",
"富源" => "FYM",
"扶余" => "FYT",
"富裕" => "FYX",
"抚州北" => "FBG",
"凤州" => "FZY",
"丰镇" => "FZC",
"范镇" => "VZK",
"固安" => "GFP",
"广安" => "VJW",
"高碑店" => "GBP",
"沟帮子" => "GBD",
"甘草店" => "GDJ",
"谷城" => "GCN",
"藁城" => "GEP",
"高村" => "GCV",
"古城镇" => "GZB",
"广德" => "GRH",
"贵定" => "GTW",
"贵定南" => "IDW",
"古东" => "GDV",
"贵港" => "GGZ",
"官高" => "GVP",
"葛根庙" => "GGT",
"干沟" => "GGL",
"甘谷" => "GGJ",
"高各庄" => "GGP",
"甘河" => "GAX",
"根河" => "GEX",
"郭家店" => "GDT",
"孤家子" => "GKT",
"高老" => "GOB",
"古浪" => "GLJ",
"皋兰" => "GEJ",
"高楼房" => "GFM",
"归流河" => "GHT",
"关林" => "GLF",
"甘洛" => "VOW",
"郭磊庄" => "GLP",
"高密" => "GMK",
"公庙子" => "GMC",
"工农湖" => "GRT",
"广宁寺" => "GNT",
"广南卫" => "GNM",
"高平" => "GPF",
"甘泉北" => "GEY",
"共青城" => "GAG",
"甘旗卡" => "GQD",
"甘泉" => "GQY",
"高桥镇" => "GZD",
"赶水" => "GSW",
"灌水" => "GST",
"孤山口" => "GSP",
"果松" => "GSL",
"高山子" => "GSD",
"嘎什甸子" => "GXD",
"高台" => "GTJ",
"高滩" => "GAY",
"古田" => "GTS",
"官厅" => "GTP",
"广通" => "GOM",
"官厅西" => "KEP",
"贵溪" => "GXG",
"涡阳" => "GYH",
"巩义" => "GXF",
"高邑" => "GIP",
"巩义南" => "GYF",
"固原" => "GUJ",
"菇园" => "GYL",
"公营子" => "GYD",
"光泽" => "GZS",
"古镇" => "GNQ",
"瓜州" => "GZJ",
"高州" => "GSQ",
"固镇" => "GEH",
"盖州" => "GXT",
"官字井" => "GOT",
"革镇堡" => "GZT",
"冠豸山" => "GSS",
"盖州西" => "GAT",
"红安" => "HWN",
"淮安南" => "AMH",
"红安西" => "VXN",
"海安县" => "HIH",
"黄柏" => "HBL",
"海北" => "HEB",
"鹤壁" => "HAF",
"华城" => "VCQ",
"合川" => "WKW",
"河唇" => "HCZ",
"汉川" => "HCN",
"海城" => "HCT",
"黑冲滩" => "HCJ",
"黄村" => "HCP",
"海城西" => "HXT",
"化德" => "HGC",
"洪洞" => "HDV",
"横峰" => "HFG",
"韩府湾" => "HXJ",
"汉沽" => "HGP",
"黄瓜园" => "HYM",
"红光镇" => "IGW",
"浑河" => "HHT",
"红花沟" => "VHD",
"黄花筒" => "HUD",
"贺家店" => "HJJ",
"和静" => "HJR",
"红江" => "HFM",
"黑井" => "HIM",
"获嘉" => "HJF",
"河津" => "HJV",
"涵江" => "HJS",
"华家" => "HJT",
"河间西" => "HXP",
"花家庄" => "HJM",
"河口南" => "HKJ",
"黄口" => "KOH",
"湖口" => "HKG",
"呼兰" => "HUB",
"葫芦岛北" => "HPD",
"浩良河" => "HHB",
"哈拉海" => "HIT",
"鹤立" => "HOB",
"桦林" => "HIB",