国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

微信公眾開發(fā)之獲取周邊酒店信息

2024-05-04 21:49:31
字體:
供稿:網(wǎng)友

關(guān)注微信公眾之后發(fā)送回復(fù)地理位置信息,即可回復(fù)周邊附近的酒店信息列表,下面我就來給各位介紹利用php是怎么實(shí)現(xiàn)這個(gè)功能,希望全子對(duì)大家有幫助.代碼如下:

  1. <?php 
  2.  //將提交過來的信息接收 
  3.  
  4. $signature = $_GET['signature']; 
  5.  
  6.  $timestamp = $_GET['timestamp']; 
  7.  
  8.  $nonce = $_GET['nonce']; 
  9.  
  10.  $echostr = $_GET['echostr']; 
  11.  
  12.  $token = "yanjiadong"
  13.  
  14.  //判斷接入網(wǎng)站 
  15.  
  16.  //進(jìn)行字典排序 
  17.  $arr = array($token,$timestamp,$nonce); 
  18.  
  19.  sort($arr); 
  20.  
  21.  //完成字符串的拼接和sha1加密 
  22.  
  23.  $result = sha1(join($arr)); 
  24.  
  25.  //判斷生成的字符串和$signature是否相等,如果相等,直接輸出$echostr,這樣網(wǎng)站接入成功 
  26.  
  27.  if($result==$signature){ 
  28.  
  29.  echo $echostr
  30.  
  31.  } 
  32.  
  33.  //接收微信公眾賬號(hào)接收到的信息 
  34.  $poststr = $GLOBALS["HTTP_RAW_POST_DATA"]; 
  35.  
  36.  $xmlObj = simplexml_load_string($poststr,'SimpleXMLElement',LIBXML_NOCDATA); 
  37.  
  38.  $ToUserName = $xmlObj->ToUserName; 
  39.  
  40.  $FromUserName = $xmlObj->FromUserName; 
  41.  
  42.  $CreateTime = $xmlObj->CreateTime; 
  43.  
  44.  $MsgType = $xmlObj->MsgType; 
  45.  
  46.  $Content = $xmlObj->Content; 
  47.  
  48. &nbsp; 
  49.  if($MsgType=='location'){ 
  50.  
  51.  $Location_X = $xmlObj->Location_X; 
  52.  
  53.  $Location_Y = $xmlObj->Location_Y; 
  54.  
  55.  $Scale = $xmlObj->Scale; 
  56.  
  57.  $Label = $xmlObj->Label; 
  58.  
  59.  $urlstr = "http://api.map.baidu.com/place/v2/search?&query=酒店&location=".$Location_X.",".$Location_Y."&radius=5000&output=json&ak=DESY8unmZnUlLB0mlowjuiRr";  //此處ak參數(shù)需要個(gè)人的百度開發(fā)序列號(hào),自己去百度申請(qǐng)下就好了 
  60.  
  61.  $jsonstr = file_get_contents($urlstr); 
  62.  
  63.  $json = json_decode($jsonstr,true); 
  64.  
  65.  $pic_640 = "http://api.map.baidu.com/staticimage?width=640&height=320&center=".$Location_Y.",".$Location_X."&zoom=15&markers=".$Location_Y.",".$Location_X."&markerStyles=l,"
  66.  
  67.  $pic_80 = "http://api.map.baidu.com/staticimage?width=80&height=80&center=".$Location_Y.",".$Location_X."&zoom=15&markers=".$Location_Y.",".$Location_X."&markerStyles=l,"
  68.  
  69.  $p_640 = file_get_contents($pic_640); 
  70.  
  71.  file_put_contents('./images/640_'.$FromUserName.".png",$p_640); 
  72.  
  73.  $p_80 = file_get_contents($pic_80); 
  74.  
  75.  file_put_contents('./images/80_'.$FromUserName.".png",$p_80); 
  76.  
  77.  echo pic_send($json['results']); 
  78.  
  79.  } 
  80.  function pic_send($arr){ 
  81.  global $ToUserName,$FromUserName
  82.  $str = "<xml> 
  83.  <ToUserName><![CDATA[".$FromUserName."]]></ToUserName> 
  84.  <FromUserName><![CDATA[".$ToUserName."]]></FromUserName> 
  85.  <CreateTime>".time()."</CreateTime> 
  86.  <MsgType><![CDATA[news]]></MsgType> 
  87.  <ArticleCount>".count($arr)."</ArticleCount> 
  88.  <Articles>"; 
  89.  foreach($arr as $k=>$v){ 
  90.  if($k==0){ 
  91.  $picurl = "http://yanjiadong.net/weixin/images/640_".$FromUserName.".png"
  92.  }else
  93.  $picurl = "http://yanjiadong.net/weixin/images/80_".$FromUserName.".png"
  94.  } 
  95.  $str .=" 
  96.  <item> 
  97.  <Title><![CDATA[".$v['name']." 地址:".$v['address']." 電話:".$v['telephone']."]]></Title> 
  98.  <Description><![CDATA[".$v['name']." 地址:".$v['address']." 電話:".$v['telephone']."]]></Description> 
  99.  <PicUrl><![CDATA[".$picurl."]]></PicUrl> 
  100.  <Url><![CDATA[http://api.map.baidu.com/place/detail?uid=".$v['uid']."&output=html&src=".$v['name']."&output=html]]></Url> 
  101.  </item>";//開源代碼Vevb.com 
  102.  } 
  103.  
  104.  $str .= "</Articles></xml>"
  105.  
  106.  return $str
  107.  } 
  108.  
  109. ?>

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 和林格尔县| 仪征市| 循化| 灯塔市| 吴川市| 汪清县| 西和县| 龙海市| 岐山县| 双江| 巴彦淖尔市| 静宁县| 闵行区| 金坛市| 永济市| 阜城县| 邢台市| 荃湾区| 巧家县| 宜州市| 武川县| 镇雄县| 富裕县| 无极县| 永泰县| 永城市| 吉首市| 昆明市| 临泽县| 永平县| 慈利县| 丰城市| 鄂托克旗| 连江县| 阿坝| 乐至县| 房山区| 乐陵市| 汉川市| 从江县| 南川市|