">
当前位置:Gxlcms > PHP教程 > 微信公众平台开发接口PHPSDK完整版_PHP教程

微信公众平台开发接口PHPSDK完整版_PHP教程

时间:2021-07-01 10:21:17 帮助过:5人阅读

官方提供的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(,            = "
 
 
 %s
 
 
 "          = (, ->FromUserName, ->ToUserName, (),             
       transmitImage(,            = "
 
 " 
          = (, ['MediaId' 
          = "
 
 
 %s
 
 
 " 
          = (, ->FromUserName, ->ToUserName,             
       transmitVoice(,            = "
 
 " 
          = (, ['MediaId' 
          = "
 
 
 %s
 
 
 " 
          = (, ->FromUserName, ->ToUserName,             
       transmitVideo(,            = "
 
 
 
 
 " 
          = (, ['MediaId'], ['ThumbMediaId'], ['Title'], ['Description' 
          = "
 
 
 %s
 
 
 " 
          = (, ->FromUserName, ->ToUserName,             
       transmitNews(,           (!(                        = "
 
 
 
 
 
 "          = ""          (                .= (, ['Title'], ['Description'], ['PicUrl'], ['Url'           = "
 
 
 %s
 
 
 
  
 " 
          = (, ->FromUserName, ->ToUserName, (), (            
       transmitMusic(,            = "
 
 
 
 
 " 
          = (, ['Title'], ['Description'], ['MusicUrl'], ['HQMusicUrl' 
          = "
 
 
 %s
 
 
 " 
          = (, ->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",    
 
 ?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/741657.htmlTechArticle官方提供的SDK只有一个文本消息功能,我们将所有消息的消息类型及事件响应都整理了进来,并且加入日志记录,代码如下: ? ("TOKEN", "w...

人气教程排行