程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> 微信公眾平台開發接口PHP SDK完整版

微信公眾平台開發接口PHP SDK完整版

編輯:關於PHP編程

官方提供的SDK只有一個文本消息功能,我們將所有消息的消息類型及事件響應都整理了進來,並且加入日志記錄,代碼如下:

 

 <? 
   
 
 ("TOKEN", "weixin" 
  =   (!(['echostr'     -> }     ->  
                   = ["echostr"         (->                              
                 = ["signature"          = ["timestamp"          = ["nonce"          =          = (, ,          (,          = (          = ( 
         ( ==                        }                 
                 = ["HTTP_RAW_POST_DATA"          (!(             ->logger("R ".              = (, 'SimpleXMLElement',              = (-> 
              (                   "event":
                      = ->receiveEvent(                                       "text":
                      = ->receiveText(                                       "image":
                      = ->receiveImage(                                       "location":
                      = ->receiveLocation(                                       "voice":
                      = ->receiveVoice(                                       "video":
                      = ->receiveVideo(                                       "link":
                      = ->receiveLink(                                      :
                      = "unknow msg type: ".                                   ->logger("T ".                       }              ""                
       receiveEvent(           = ""          (->               "subscribe":
                  = "歡迎關注方倍工作室 "                  .= (!(->EventKey))?("\n來自二維碼場景 ".("qrscene_","",->EventKey)):""                               "unsubscribe":
                  = "取消關注"                               "SCAN":
                  = "掃描場景 ".->                               "CLICK":
                  (->                       "COMPANY":
                          = "方倍工作室提供互聯網相關產品與服務。"                                              :
                          = "點擊菜單:".->                                                         "LOCATION":
                  = "上傳位置:緯度 ".->Latitude.";經度 ".->                              :
                  = "receive a new event: ".->                            = ->transmitText(,             
       receiveText(           = (->          (               "文本":
                  = "這是個文本消息"                               "圖文":
              "單圖文":
                 [] = ("Title"=>"單圖文標題", "Description"=>"單圖文內容", "PicUrl"=>"http://discuz.comli.com/weixin/weather/icon/cartoon.jpg", "Url" =>"http://m.cnblogs.com/?u=txw1958"                               "多圖文":
                 [] = ("Title"=>"多圖文1標題", "Description"=>"", "PicUrl"=>"http://discuz.comli.com/weixin/weather/icon/cartoon.jpg", "Url" =>"http://m.cnblogs.com/?u=txw1958"                 [] = ("Title"=>"多圖文2標題", "Description"=>"", "PicUrl"=>"http://d.hiphotos.bdimg.com/wisegame/pic/item/f3529822720e0cf3ac9f1ada0846f21fbe09aaa3.jpg", "Url" =>"http://m.cnblogs.com/?u=txw1958"                 [] = ("Title"=>"多圖文3標題", "Description"=>"", "PicUrl"=>"http://g.hiphotos.bdimg.com/wisegame/pic/item/18cb0a46f21fbe090d338acc6a600c338644adfd.jpg", "Url" =>"http://m.cnblogs.com/?u=txw1958"                               "音樂":
                  = ("Title"=>"最炫民族風", "Description"=>"歌手:鳳凰傳奇", "MusicUrl"=>"http://121.199.4.61/music/zxmzf.mp3", "HQMusicUrl"=>"http://121.199.4.61/music/zxmzf.mp3"                              :
                  = "當前時間:".("Y-m-d H:i:s",                           ((              (([0]['PicUrl'                  = ->transmitNews(,              }  ((['MusicUrl'                  = ->transmitMusic(,           }              = ->transmitText(,              
       receiveImage(           = ("MediaId"=>->          = ->transmitImage(,             
       receiveLocation(           = "你發送的是位置,緯度為:".->Location_X.";經度為:".->Location_Y.";縮放級別為:".->Scale.";位置為:".->          = ->transmitText(,             
       receiveVoice(           ((->              = ("MediaId"=>->              = ->transmitVoice(,          }              = "你剛才說的是:".->              = ->transmitText(,   
            
       receiveVideo(           = ("MediaId"=>->MediaId, "ThumbMediaId"=>->ThumbMediaId, "Title"=>"", "Description"=>""          = ->transmitVideo(,             
       receiveLink(           = "你發送的是鏈接,標題為:".->Title.";內容為:".->Description.";鏈接地址為:".->          = ->transmitText(,             
       transmitText(,            = "      </xml>"          = (, ->FromUserName, ->ToUserName, (),             
       transmitImage(,            = "  </Image>" 
          = (, ['MediaId' 
          = "     
 </xml>" 
          = (, ->FromUserName, ->ToUserName,             
       transmitVoice(,            = "  </Voice>" 
          = (, ['MediaId' 
          = "     
 </xml>" 
          = (, ->FromUserName, ->ToUserName,             
       transmitVideo(,            = "     </Video>" 
          = (, ['MediaId'], ['ThumbMediaId'], ['Title'], ['Description' 
          = "     
 </xml>" 
          = (, ->FromUserName, ->ToUserName,             
       transmitNews(,           (!(                        = "      "          = ""          (                .= (, ['Title'], ['Description'], ['PicUrl'], ['Url'           = "         </xml>" 
          = (, ->FromUserName, ->ToUserName, (), (            
       transmitMusic(,            = "     </Music>" 
          = (, ['Title'], ['Description'], ['MusicUrl'], ['HQMusicUrl' 
          = "     
 </xml>" 
          = (, ->FromUserName, ->ToUserName,             
       logger(          ((['HTTP_APPNAME'])){   
             sae_set_display_errors(             sae_debug(             sae_set_display_errors(         } (['REMOTE_ADDR'] != "127.0.0.1"){ 
              = 10000              = "log.xml"             (() and ((()) > )){(             (, ('H:i:s')." ".."\r\n",    
 
 ?>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved