365体育备用网址报道5.2.7菜单事情推送_365体育备用网址官网资讯

用户点击菜单之后,微信会将事情推送给接口程序,相应的接口参数及说明如表5-3所示。

表5-4 自定义菜单参数说明

用户点击自定义菜单后,接口程序收到的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类型的菜单后,调用宾利娱乐城国际备用里面的照相机功能,而照相以后再发过来时,就收到一个大发888网站消息。点击菜单时的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类型的菜单之后,先推送菜单事情推送给开拓者,然后再推送大发888网站消息,点击菜单时的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>

点击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;
}
------分隔线----------------------------

公布评论 (98人察看0条评论)
请自觉遵守互联网相关的政策法规,严禁公布色情、暴力、反动的言论。
用户名: 验证码: 点击我更换大发888网站
最新评论