微信菜单事件推送亚洲必赢app在哪下载

By admin in 亚洲必赢app在哪下载 on 2019年3月29日

用户点击菜单之后,微信会将事件推送给接口程序,相应的接口参数及注解

亚洲必赢app在哪下载 1

用户点击自定义菜单后,接口程序收到的XML数据包如下所示:

<xml>
    <ToUserName><![CDATA[gh_36dd0f0b3132]]></ToUserName>
    <FromUserName><![CDATA[oQW8FuN_DFnKZwBaUKQ1RJD2Tr9M]]></FromUserName>
    <CreateTime>1468050882</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[CLICK]]></Event>
    <EventKey><![CDATA[TEXT]]></EventKey>
</xml>

按钮类型为view的菜谱点击后,上报的XML如下所示:

<xml>
    <ToUserName><![CDATA[gh_36dd0f0b3132]]></ToUserName>
    <FromUserName><![CDATA[oQW8FuN_DFnKZwBaUKQ1RJD2Tr9M]]></FromUserName>
    <CreateTime>1468050934</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[VIEW]]></Event>
    <EventKey><![CDATA[http://xw.qq.com/]]></EventKey>
    <MenuId>410418124</MenuId>
</xml>

点击scancode_push类型的食谱时,接口程序收到的XML数据包如下所示。
  微信会直接运转解码后的情节,比如直接进加入关贸总协定组织切界面。

<xml>
    <ToUserName><![CDATA[gh_36dd0f0b3132]]></ToUserName>
    <FromUserName><![CDATA[oQW8FuN_DFnKZwBaUKQ1RJD2Tr9M]]></FromUserName>
    <CreateTime>1468051082</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[scancode_push]]></Event>
    <EventKey><![CDATA[rselfmenu_2_2]]></EventKey>
    <ScanCodeInfo>
        <ScanType><![CDATA[qrcode]]></ScanType>
        <ScanResult><![CDATA[http://weixin.qq.com/r/l0Ozq9-EbYISrZvI9xaF]]></ScanResult>
    </ScanCodeInfo>
</xml>

点击scancode_waitmsg类型的菜系时,接口程序收到的XML数据包如下所示:

<xml>
    <ToUserName><![CDATA[gh_36dd0f0b3132]]></ToUserName>
    <FromUserName><![CDATA[oQW8FuN_DFnKZwBaUKQ1RJD2Tr9M]]></FromUserName>
    <CreateTime>1468051112</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[scancode_waitmsg]]></Event>
    <EventKey><![CDATA[rselfmenu_2_1]]></EventKey>
    <ScanCodeInfo>
        <ScanType><![CDATA[qrcode]]></ScanType>
        <ScanResult><![CDATA[http://weixin.qq.com/r/l0Ozq9-EbYISrZvI9xaF]]></ScanResult>
    </ScanCodeInfo>
</xml>

点击pic_sysphoto类型的菜系后,调用手提式有线电话机里面包车型地铁照相机功效,而拍照今后再发过来时,就接收二个图片信息。点击菜单时的XML数据如下所示:

<xml>
    <ToUserName><![CDATA[gh_36dd0f0b3132]]></ToUserName>
    <FromUserName><![CDATA[oQW8FuNH_V1zk4x3zTN1IMoAZDW0]]></FromUserName>
    <CreateTime>1468051307</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[pic_sysphoto]]></Event>
    <EventKey><![CDATA[rselfmenu_2_3]]></EventKey>
    <SendPicsInfo>
        <Count>1</Count>
        <PicList>
            <item>
                <PicMd5Sum><![CDATA[4cc7f5ab2c499b01655e99a868ef3519]]></PicMd5Sum>
            </item>
        </PicList>
    </SendPicsInfo>
</xml>

点击pic_photo_or_album类型的菜单之后,先推送菜单事件推送给开发者,然后再推送图片音信,点击菜单时的XML数据如下所示:

<xml>
    <ToUserName><![CDATA[gh_36dd0f0b3132]]></ToUserName>
    <FromUserName><![CDATA[oQW8FuNH_V1zk4x3zTN1IMoAZDW0]]></FromUserName>
    <CreateTime>1468051528</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[pic_photo_or_album]]></Event>
    <EventKey><![CDATA[rselfmenu_2_4]]></EventKey>
    <SendPicsInfo>
        <Count>2</Count>
        <PicList>
            <item>
                <PicMd5Sum><![CDATA[b5c23feac0987db7ddda1b0a3addba9d]]></PicMd5Sum>
            </item>
            <item>
                <PicMd5Sum><![CDATA[59c3eb7e2124a75986295b8842573951]]></PicMd5Sum>
            </item>
        </PicList>
    </SendPicsInfo>
</xml>

亚洲必赢app在哪下载,点击pic_weixin类型的食谱时,微信客户端将调起系统相机,用户能够选用已有照片也许拓展录像,微信会将照片发送给开发者,上面是贰次选取3张相片时的XML数据:

<xml>
    <ToUserName><![CDATA[gh_36dd0f0b3132]]></ToUserName>
    <FromUserName><![CDATA[oQW8FuNH_V1zk4x3zTN1IMoAZDW0]]></FromUserName>
    <CreateTime>1468051592</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[pic_weixin]]></Event>
    <EventKey><![CDATA[rselfmenu_2_5]]></EventKey>
    <SendPicsInfo>
        <Count>3</Count>
        <PicList>
            <item>
                <PicMd5Sum><![CDATA[59c3eb7e2124a75986295b8842573951]]></PicMd5Sum>
            </item>
            <item>
                <PicMd5Sum><![CDATA[b5c23feac0987db7ddda1b0a3addba9d]]></PicMd5Sum>
            </item>
            <item>
                <PicMd5Sum><![CDATA[4cc7f5ab2c499b01655e99a868ef3519]]></PicMd5Sum>
            </item>
        </PicList>
    </SendPicsInfo>
</xml>

点击location_select类型的菜谱之后,将会调起发送地方功用,在用户发送地点然后,会再推送一个地理地点消息功用给用户,
XML数据如下所示。

<xml>
    <ToUserName><![CDATA[gh_36dd0f0b3132]]></ToUserName>
    <FromUserName><![CDATA[oQW8FuNH_V1zk4x3zTN1IMoAZDW0]]></FromUserName>
    <CreateTime>1468051658</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[location_select]]></Event>
    <EventKey><![CDATA[SIGNIN]]></EventKey>
    <SendLocationInfo>
        <Location_X><![CDATA[22.53996467590332]]></Location_X>
        <Location_Y><![CDATA[113.93487548828125]]></Location_Y>
        <Scale><![CDATA[17]]></Scale>
        <Label><![CDATA[广东省深圳市南山区深南大道10000号]]></Label>
        <Poiname><![CDATA[腾讯大厦]]></Poiname>
    </SendLocationInfo>
</xml>

消息接口中,响应自定义菜单点击事件的大旨代码如下所示:

//接收事件消息
private function receiveEvent($object)
{
    $content = "";
    switch ($object->Event)
    {
        case "subscribe":
            $content = "欢迎关注方倍工作室 ";
            $content .= (!empty($object->EventKey))?("\n来自二维码场景 ".str_replace("qrscene_","",$object->EventKey)):"";
            break;
        case "unsubscribe":
            $content = "取消关注";
            break;
        case "CLICK":
            switch ($object->EventKey)
            {
                case "COMPANY":
                    $content = array();
                    $content[] = array("Title"=>"方倍工作室", "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 "VIEW":
            $content = "跳转链接 ".$object->EventKey;
            break;
        case "SCAN":
            $content = "扫描场景 ".$object->EventKey;
            break;
        case "LOCATION":
            $content = "上传位置:纬度 ".$object->Latitude.";经度 ".$object->Longitude;
            break;
        case "scancode_waitmsg":
            $content = "扫码带提示:类型 ".$object->ScanCodeInfo->ScanType." 结果:".$object->ScanCodeInfo->ScanResult;
            break;
        case "scancode_push":
            $content = "扫码推事件";
            break;
        case "pic_sysphoto":
            $content = "系统拍照";
            break;
        case "pic_weixin":
            $content = "相册发图:数量 ".$object->SendPicsInfo->Count;
            break;
        case "pic_photo_or_album":
            $content = "拍照或者相册:数量 ".$object->SendPicsInfo->Count;
            break;
        case "location_select":
            $content = "发送位置:标签 ".$object->SendLocationInfo->Label;
            break;
        default:
            $content = "receive a new event: ".$object->Event." \n技术支持 方倍工作室";
            break;
    }

    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);
    }
    return $result;
}

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 亚洲必赢app官方下载 版权所有