search
HomeBackend DevelopmentPHP TutorialWeChat public platform development (104) Scan the custom menu, send pictures, and send geographical location, 104 scan_PHP tutorial

WeChat public platform development (104) Scan the custom menu, send pictures, send location, 104 scan

Keywords: WeChat public platform custom menu Scan Scan hair pictures and send geographical location
Author: Fangbei Studio
Original text: http://www.cnblogs.com/txw1958/p/weixin-menu-new-type.html

Customized menus can help official accounts enrich their interfaces, allowing users to understand the important functions of official accounts better and faster. WeChat has added the ability to launch a scan (supports QR code/one-dimensional code), send pictures, and send geographical location after clicking on the menu, which needs to be developed and implemented. Official accounts with original custom menu development permissions can obtain the above capabilities.

In this WeChat public platform development tutorial, we will introduce how to develop functions such as scanning, sending pictures, and sending geographical location on the custom menu. For the development of original click and jump events, please refer to WeChat Public Platform Development (58) Custom Menu.


This article is divided into the following two parts:

1. Scan code push event scancode_push
After the user clicks the button, the WeChat client will launch the scan tool. After completing the scan operation, the scan result will be displayed (if it is a URL, the URL will be entered), and the The result of scanning the code is sent to the developer, who can send messages.

2. Scan the code to push the event, and the "Message Receiving" prompt box scancode_waitmsg will pop up
After the user clicks the button, the WeChat client will activate the scan tool. After completing the scan operation, the result of the scan will be Pass it to the developer, put away the scanning tool at the same time, and then the "Message Receiving" prompt box will pop up, and you may receive a message from the developer.

3. Pop up the system to take pictures and send pictures pic_sysphoto
After the user clicks the button, the WeChat client will call up the system camera. After completing the photo operation, the taken photos will be sent to the developer and the event will be pushed to the developer. Put away the system camera and you may receive a message from the developer.

4. Pop up to take a photo or send a picture to an album pic_photo_or_album
After the user clicks the button, the WeChat client will pop up a selector for the user to choose "take a photo" or "select from the mobile phone album". After the user chooses, he will go through the other two processes.

5. Pop up the WeChat photo album sender pic_weixin
After the user clicks the button, the WeChat client will call up the WeChat photo album. After completing the selection operation, the selected photos will be sent to the developer's server and the event will be pushed to the development If you close the photo album at the same time, you may receive a message from the developer later.

6. Pop up the location selector location_select
After the user clicks the button, the WeChat client will call up the location selection tool. After completing the selection operation, the selected location will be sent to the developer's server, and at the same time, it will be closed The location selection tool may then receive a message from the developer.

The above new capabilities only support WeChat iPhone 5.4.1 or above, and Android 5.4 or above WeChat users. WeChat users with older versions will not respond after clicking, and developers will not be able to receive event push normally.

Interface call request description

http request method: POST (please use https protocol)

https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN

An example of a button request is as follows

<span>{
    </span><span>"</span><span>button</span><span>"</span><span>: [
        {
            </span><span>"</span><span>name</span><span>"</span>: <span>"</span><span>扫码</span><span>"</span><span>, 
            </span><span>"</span><span>sub_button</span><span>"</span><span>: [
                {
                    </span><span>"</span><span>type</span><span>"</span>: <span>"</span><span>scancode_waitmsg</span><span>"</span><span>, 
                    </span><span>"</span><span>name</span><span>"</span>: <span>"</span><span>扫码带提示</span><span>"</span><span>, 
                    </span><span>"</span><span>key</span><span>"</span>: <span>"</span><span>rselfmenu_0_0</span><span>"</span><span>, 
                    </span><span>"</span><span>sub_button</span><span>"</span><span>: [ ]
                }, 
                {
                    </span><span>"</span><span>type</span><span>"</span>: <span>"</span><span>scancode_push</span><span>"</span><span>, 
                    </span><span>"</span><span>name</span><span>"</span>: <span>"</span><span>扫码推事件</span><span>"</span><span>, 
                    </span><span>"</span><span>key</span><span>"</span>: <span>"</span><span>rselfmenu_0_1</span><span>"</span><span>, 
                    </span><span>"</span><span>sub_button</span><span>"</span><span>: [ ]
                }
            ]
        }, 
        {
            </span><span>"</span><span>name</span><span>"</span>: <span>"</span><span>发图</span><span>"</span><span>, 
            </span><span>"</span><span>sub_button</span><span>"</span><span>: [
                {
                    </span><span>"</span><span>type</span><span>"</span>: <span>"</span><span>pic_sysphoto</span><span>"</span><span>, 
                    </span><span>"</span><span>name</span><span>"</span>: <span>"</span><span>系统拍照发图</span><span>"</span><span>, 
                    </span><span>"</span><span>key</span><span>"</span>: <span>"</span><span>rselfmenu_1_0</span><span>"</span><span>, 
                   </span><span>"</span><span>sub_button</span><span>"</span><span>: [ ]
                 }, 
                {
                    </span><span>"</span><span>type</span><span>"</span>: <span>"</span><span>pic_photo_or_album</span><span>"</span><span>, 
                    </span><span>"</span><span>name</span><span>"</span>: <span>"</span><span>拍照或者相册发图</span><span>"</span><span>, 
                    </span><span>"</span><span>key</span><span>"</span>: <span>"</span><span>rselfmenu_1_1</span><span>"</span><span>, 
                    </span><span>"</span><span>sub_button</span><span>"</span><span>: [ ]
                }, 
                {
                    </span><span>"</span><span>type</span><span>"</span>: <span>"</span><span>pic_weixin</span><span>"</span><span>, 
                    </span><span>"</span><span>name</span><span>"</span>: <span>"</span><span>微信相册发图</span><span>"</span><span>, 
                    </span><span>"</span><span>key</span><span>"</span>: <span>"</span><span>rselfmenu_1_2</span><span>"</span><span>, 
                    </span><span>"</span><span>sub_button</span><span>"</span><span>: [ ]
                }
            ]
        }, 
        {
            </span><span>"</span><span>name</span><span>"</span>: <span>"</span><span>发送位置</span><span>"</span><span>, 
            </span><span>"</span><span>type</span><span>"</span>: <span>"</span><span>location_select</span><span>"</span><span>, 
            </span><span>"</span><span>key</span><span>"</span>: <span>"</span><span>rselfmenu_2_0</span><span>"</span><span>
        }
    ]
}</span>

Parameter Description

Parameter Is it necessary Explanation
button Yes First-level menu array, the number should be 1~3
sub_button No Secondary menu array, the number should be 1~5
type Yes Menu response action type
name Yes Menu title, no more than 16 bytes, submenu no more than 40 bytes
key Click and other click types are required Menu KEY value, used for message interface push, no more than 128 bytes
url View type is required Web page link, the user can click the menu to open the link, no more than 256 bytes
参数 是否必须 说明
button 一级菜单数组,个数应为1~3个
sub_button 二级菜单数组,个数应为1~5个
type 菜单的响应动作类型
name 菜单标题,不超过16个字节,子菜单不超过40个字节
key click等点击类型必须 菜单KEY值,用于消息接口推送,不超过128字节
url view类型必须 网页链接,用户点击菜单可打开链接,不超过256字节

 

 

二、生成菜单

菜单具体的生成方法,与之前是一样的,先生成access token,再将菜单post内容提交给微信服务器,具体代码及方法可以参考 微信公众平台开发(58)自定义菜单。

生成后的效果如下如示:

 

 

三、响应菜单点击

响应菜单点击,则需要在接口文件中添加新的EventKey事件的响应,并回复相应的内容。

相关代码如下

<span> 1</span>     <span>//</span><span>接收事件消息</span>
<span> 2</span>     <span>private</span> <span>function</span> receiveEvent(<span>$object</span><span>)
</span><span> 3</span> <span>    {
</span><span> 4</span>         <span>$content</span> = ""<span>;
</span><span> 5</span>         <span>switch</span> (<span>$object</span>-><span>Event)
</span><span> 6</span> <span>        {
</span><span> 7</span>             <span>case</span> "subscribe":
<span> 8</span>                 <span>$content</span> = "欢迎关注方倍工作室 "<span>;
</span><span> 9</span>                 <span>$content</span> .= (!<span>empty</span>(<span>$object</span>->EventKey))?("\n来自二维码场景 ".<span>str_replace</span>("qrscene_","",<span>$object</span>->EventKey)):""<span>;
</span><span>10</span>                 <span>break</span><span>;
</span><span>11</span>             <span>case</span> "unsubscribe":
<span>12</span>                 <span>$content</span> = "取消关注"<span>;
</span><span>13</span>                 <span>break</span><span>;
</span><span>14</span>             <span>case</span> "CLICK":
<span>15</span>                 <span>switch</span> (<span>$object</span>-><span>EventKey)
</span><span>16</span> <span>                {
</span><span>17</span>                     <span>case</span> "COMPANY":
<span>18</span>                         <span>$content</span> = <span>array</span><span>();
</span><span>19</span>                         <span>$content</span>[] = <span>array</span>("Title"=>"方倍工作室", "Description"=>"", "PicUrl"=>"http://discuz.comli.com/weixin/weather/icon/cartoon.jpg", "Url" =>"http://m.cnblogs.com/?u=txw1958"<span>);
</span><span>20</span>                         <span>break</span><span>;
</span><span>21</span>                     <span>default</span>:
<span>22</span>                         <span>$content</span> = "点击菜单:".<span>$object</span>-><span>EventKey;
</span><span>23</span>                         <span>break</span><span>;
</span><span>24</span> <span>                }
</span><span>25</span>                 <span>break</span><span>;
</span><span>26</span>             <span>case</span> "VIEW":
<span>27</span>                 <span>$content</span> = "跳转链接 ".<span>$object</span>-><span>EventKey;
</span><span>28</span>                 <span>break</span><span>;
</span><span>29</span>             <span>case</span> "SCAN":
<span>30</span>                 <span>$content</span> = "扫描场景 ".<span>$object</span>-><span>EventKey;
</span><span>31</span>                 <span>break</span><span>;
</span><span>32</span>             <span>case</span> "LOCATION":
<span>33</span>                 <span>$content</span> = "上传位置:纬度 ".<span>$object</span>->Latitude.";经度 ".<span>$object</span>-><span>Longitude;
</span><span>34</span>                 <span>break</span><span>;
</span><span>35</span>             <span>case</span> "scancode_waitmsg":
<span>36</span>                 <span>$content</span> = "扫码带提示:类型 ".<span>$object</span>->ScanCodeInfo->ScanType." 结果:".<span>$object</span>->ScanCodeInfo-><span>ScanResult;
</span><span>37</span>                 <span>break</span><span>;
</span><span>38</span>             <span>case</span> "scancode_push":
<span>39</span>                 <span>$content</span> = "扫码推事件"<span>;
</span><span>40</span>                 <span>break</span><span>;
</span><span>41</span>             <span>case</span> "pic_sysphoto":
<span>42</span>                 <span>$content</span> = "系统拍照"<span>;
</span><span>43</span>                 <span>break</span><span>;
</span><span>44</span>             <span>case</span> "pic_weixin":
<span>45</span>                 <span>$content</span> = "相册发图:数量 ".<span>$object</span>->SendPicsInfo-><span>Count</span><span>;
</span><span>46</span>                 <span>break</span><span>;
</span><span>47</span>             <span>case</span> "pic_photo_or_album":
<span>48</span>                 <span>$content</span> = "拍照或者相册:数量 ".<span>$object</span>->SendPicsInfo-><span>Count</span><span>;
</span><span>49</span>                 <span>break</span><span>;
</span><span>50</span>             <span>case</span> "location_select":
<span>51</span>                 <span>$content</span> = "发送位置:标签 ".<span>$object</span>->SendLocationInfo-><span>Label;
</span><span>52</span>                 <span>break</span><span>;
</span><span>53</span>             <span>default</span>:
<span>54</span>                 <span>$content</span> = "receive a new event: ".<span>$object</span>->Event." \n技术支持 方倍工作室"<span>;
</span><span>55</span>                 <span>break</span><span>;
</span><span>56</span> <span>        }
</span><span>57</span> 
<span>58</span>         <span>if</span>(<span>is_array</span>(<span>$content</span><span>)){
</span><span>59</span>             <span>if</span> (<span>isset</span>(<span>$content</span>[0]['PicUrl'<span>])){
</span><span>60</span>                 <span>$result</span> = <span>$this</span>->transmitNews(<span>$object</span>, <span>$content</span><span>);
</span><span>61</span>             }<span>else</span> <span>if</span> (<span>isset</span>(<span>$content</span>['MusicUrl'<span>])){
</span><span>62</span>                 <span>$result</span> = <span>$this</span>->transmitMusic(<span>$object</span>, <span>$content</span><span>);
</span><span>63</span> <span>            }
</span><span>64</span>         }<span>else</span><span>{
</span><span>65</span>             <span>$result</span> = <span>$this</span>->transmitText(<span>$object</span>, <span>$content</span><span>);
</span><span>66</span> <span>        }
</span><span>67</span>         <span>return</span> <span>$result</span><span>;
</span><span>68</span>     }

 各项类型推送给后台的xml详解如下

scancode_waitmsg,回应该事件给用户,用户可收到消息

<span><</span><span>xml</span><span>></span>
    <span><</span><span>ToUserName</span><span>></span><span><![CDATA[</span><span>gh_82479813ed64</span><span>]]></span><span></</span><span>ToUserName</span><span>></span>
    <span><</span><span>FromUserName</span><span>></span><span><![CDATA[</span><span>ojpX_jig-gyi3_Q9fHXQ4rdHniQs</span><span>]]></span><span></</span><span>FromUserName</span><span>></span>
    <span><</span><span>CreateTime</span><span>></span>1412075435<span></</span><span>CreateTime</span><span>></span>
    <span><</span><span>MsgType</span><span>></span><span><![CDATA[</span><span>event</span><span>]]></span><span></</span><span>MsgType</span><span>></span>
    <span><</span><span>Event</span><span>></span><span><![CDATA[</span><span>scancode_waitmsg</span><span>]]></span><span></</span><span>Event</span><span>></span>
    <span><</span><span>EventKey</span><span>></span><span><![CDATA[</span><span>rselfmenu_0_0</span><span>]]></span><span></</span><span>EventKey</span><span>></span>
    <span><</span><span>ScanCodeInfo</span><span>></span>
        <span><</span><span>ScanType</span><span>></span><span><![CDATA[</span><span>qrcode</span><span>]]></span><span></</span><span>ScanType</span><span>></span>
        <span><</span><span>ScanResult</span><span>></span><span><![CDATA[</span><span>http://weixin.qq.com/r/pUNnf4HEX9wgrcUc9xa3</span><span>]]></span><span></</span><span>ScanResult</span><span>></span>
        <span><</span><span>EventKey</span><span>></span><span><![CDATA[</span><span>rselfmenu_0_0</span><span>]]></span><span></</span><span>EventKey</span><span>></span>
    <span></</span><span>ScanCodeInfo</span><span>></span>
<span></</span><span>xml</span><span>></span>

scancode_push,回应该事件给用户,用户不能收到消息

<span><</span><span>xml</span><span>></span>
    <span><</span><span>ToUserName</span><span>></span><span><![CDATA[</span><span>gh_82479813ed64</span><span>]]></span><span></</span><span>ToUserName</span><span>></span>
    <span><</span><span>FromUserName</span><span>></span><span><![CDATA[</span><span>ojpX_jig-gyi3_Q9fHXQ4rdHniQs</span><span>]]></span><span></</span><span>FromUserName</span><span>></span>
    <span><</span><span>CreateTime</span><span>></span>1412075451<span></</span><span>CreateTime</span><span>></span>
    <span><</span><span>MsgType</span><span>></span><span><![CDATA[</span><span>event</span><span>]]></span><span></</span><span>MsgType</span><span>></span>
    <span><</span><span>Event</span><span>></span><span><![CDATA[</span><span>scancode_push</span><span>]]></span><span></</span><span>Event</span><span>></span>
    <span><</span><span>EventKey</span><span>></span><span><![CDATA[</span><span>rselfmenu_0_1</span><span>]]></span><span></</span><span>EventKey</span><span>></span>
    <span><</span><span>ScanCodeInfo</span><span>></span>
        <span><</span><span>ScanType</span><span>></span><span><![CDATA[</span><span>qrcode</span><span>]]></span><span></</span><span>ScanType</span><span>></span>
        <span><</span><span>ScanResult</span><span>></span><span><![CDATA[</span><span>http://weixin.qq.com/r/pUNnf4HEX9wgrcUc9xa3</span><span>]]></span><span></</span><span>ScanResult</span><span>></span>
        <span><</span><span>EventKey</span><span>></span><span><![CDATA[</span><span>rselfmenu_0_1</span><span>]]></span><span></</span><span>EventKey</span><span>></span>
    <span></</span><span>ScanCodeInfo</span><span>></span>
<span></</span><span>xml</span><span>></span>

pic_weixin ,下面是一次推送3张相片时的数据

<span><</span><span>xml</span><span>></span>
    <span><</span><span>ToUserName</span><span>></span><span><![CDATA[</span><span>gh_82479813ed64</span><span>]]></span><span></</span><span>ToUserName</span><span>></span>
    <span><</span><span>FromUserName</span><span>></span><span><![CDATA[</span><span>ojpX_jig-gyi3_Q9fHXQ4rdHniQs</span><span>]]></span><span></</span><span>FromUserName</span><span>></span>
    <span><</span><span>CreateTime</span><span>></span>1412075552<span></</span><span>CreateTime</span><span>></span>
    <span><</span><span>MsgType</span><span>></span><span><![CDATA[</span><span>event</span><span>]]></span><span></</span><span>MsgType</span><span>></span>
    <span><</span><span>Event</span><span>></span><span><![CDATA[</span><span>pic_weixin</span><span>]]></span><span></</span><span>Event</span><span>></span>
    <span><</span><span>EventKey</span><span>></span><span><![CDATA[</span><span>rselfmenu_1_2</span><span>]]></span><span></</span><span>EventKey</span><span>></span>
    <span><</span><span>SendPicsInfo</span><span>></span>
        <span><</span><span>Count</span><span>></span>3<span></</span><span>Count</span><span>></span>
        <span><</span><span>PicList</span><span>></span>
            <span><</span><span>item</span><span>></span>
                <span><</span><span>PicMd5Sum</span><span>></span><span><![CDATA[</span><span>a6ab74b73a298f49f6fc66f41f88d3c7</span><span>]]></span><span></</span><span>PicMd5Sum</span><span>></span>
            <span></</span><span>item</span><span>></span>
            <span><</span><span>item</span><span>></span>
                <span><</span><span>PicMd5Sum</span><span>></span><span><![CDATA[</span><span>5b9aea2b3683c5c21aaf3629739cafd9</span><span>]]></span><span></</span><span>PicMd5Sum</span><span>></span>
            <span></</span><span>item</span><span>></span>
            <span><</span><span>item</span><span>></span>
                <span><</span><span>PicMd5Sum</span><span>></span><span><![CDATA[</span><span>2325ff3f39705ac987d3e0660906791d</span><span>]]></span><span></</span><span>PicMd5Sum</span><span>></span>
            <span></</span><span>item</span><span>></span>
        <span></</span><span>PicList</span><span>></span>
        <span><</span><span>EventKey</span><span>></span><span><![CDATA[</span><span>rselfmenu_1_2</span><span>]]></span><span></</span><span>EventKey</span><span>></span>
    <span></</span><span>SendPicsInfo</span><span>></span>
<span></</span><span>xml</span><span>></span>

回应上述消息,用户收不到,但微信会继续推送3个图片消息给接口

<span><</span><span>xml</span><span>></span>
    <span><</span><span>ToUserName</span><span>></span><span><![CDATA[</span><span>gh_82479813ed64</span><span>]]></span><span></</span><span>ToUserName</span><span>></span>
    <span><</span><span>FromUserName</span><span>></span><span><![CDATA[</span><span>ojpX_jig-gyi3_Q9fHXQ4rdHniQs</span><span>]]></span><span></</span><span>FromUserName</span><span>></span>
    <span><</span><span>CreateTime</span><span>></span>1412075562<span></</span><span>CreateTime</span><span>></span>
    <span><</span><span>MsgType</span><span>></span><span><![CDATA[</span><span>image</span><span>]]></span><span></</span><span>MsgType</span><span>></span>
    <span><</span><span>PicUrl</span><span>></span><span><![CDATA[</span><span>http://mmbiz.qpic.cn/mmbiz/qOTIrRtMKFxZQo3cQ6vYxmfteo0fw2Y00MuuFS6OjlNvTkx0nBQJibjjafQMf4dCtJwyMeP5e3SQCuJpcoJdb8Q/0</span><span>]]></span><span></</span><span>PicUrl</span><span>></span>
    <span><</span><span>MsgId</span><span>></span>6064818358471506877<span></</span><span>MsgId</span><span>></span>
    <span><</span><span>MediaId</span><span>></span><span><![CDATA[</span><span>AM8Gbiu7S2vTIMS2l9zNCWiMCpeM8wccmKdFxmstHiuAybCbB-08dTQJN40cCIBD</span><span>]]></span><span></</span><span>MediaId</span><span>></span>
<span></</span><span>xml</span><span>></span>
<span><</span><span>xml</span><span>></span>
    <span><</span><span>ToUserName</span><span>></span><span><![CDATA[</span><span>gh_82479813ed64</span><span>]]></span><span></</span><span>ToUserName</span><span>></span>
    <span><</span><span>FromUserName</span><span>></span><span><![CDATA[</span><span>ojpX_jig-gyi3_Q9fHXQ4rdHniQs</span><span>]]></span><span></</span><span>FromUserName</span><span>></span>
    <span><</span><span>CreateTime</span><span>></span>1412075564<span></</span><span>CreateTime</span><span>></span>
    <span><</span><span>MsgType</span><span>></span><span><![CDATA[</span><span>image</span><span>]]></span><span></</span><span>MsgType</span><span>></span>
    <span><</span><span>PicUrl</span><span>></span><span><![CDATA[</span><span>http://mmbiz.qpic.cn/mmbiz/qOTIrRtMKFxZQo3cQ6vYxmfteo0fw2Y0ellMniarWto4zL0pWKhr6a0FSARDeXprSgd0JmgU0YQo2iagGsYc1iaLA/0</span><span>]]></span><span></</span><span>PicUrl</span><span>></span>
    <span><</span><span>MsgId</span><span>></span>6064818367061441471<span></</span><span>MsgId</span><span>></span>
    <span><</span><span>MediaId</span><span>></span><span><![CDATA[</span><span>2CJKZ2mft-5hWEkVcVmnKwyvp3y59Uzv7YdpBsnGIyTlkMNb0ytU4oimTgimBGyP</span><span>]]></span><span></</span><span>MediaId</span><span>></span>
<span></</span><span>xml</span><span>></span>
<span><</span><span>xml</span><span>></span>
    <span><</span><span>ToUserName</span><span>></span><span><![CDATA[</span><span>gh_82479813ed64</span><span>]]></span><span></</span><span>ToUserName</span><span>></span>
    <span><</span><span>FromUserName</span><span>></span><span><![CDATA[</span><span>ojpX_jig-gyi3_Q9fHXQ4rdHniQs</span><span>]]></span><span></</span><span>FromUserName</span><span>></span>
    <span><</span><span>CreateTime</span><span>></span>1412075567<span></</span><span>CreateTime</span><span>></span>
    <span><</span><span>MsgType</span><span>></span><span><![CDATA[</span><span>image</span><span>]]></span><span></</span><span>MsgType</span><span>></span>
    <span><</span><span>PicUrl</span><span>></span><span><![CDATA[</span><span>http://mmbiz.qpic.cn/mmbiz/qOTIrRtMKFxZQo3cQ6vYxmfteo0fw2Y0mwQoENttnmYAz0VTicY3xkO0lhn9mE5r3FB4cF04kia50riajcjY1qvzA/0</span><span>]]></span><span></</span><span>PicUrl</span><span>></span>
    <span><</span><span>MsgId</span><span>></span>6064818379946343361<span></</span><span>MsgId</span><span>></span>
    <span><</span><span>MediaId</span><span>></span><span><![CDATA[</span><span>VICm1-y8w_MmdpcLYWP0u12HVXrWdhm3c3tdq1PTsbiFFgH6YOcmmIEbZ27z-Qcl</span><span>]]></span><span></</span><span>MediaId</span><span>></span>
<span></</span><span>xml</span><span>></span>

上述多个图片消息,后台收到都能进行单独回应,用户可以收到响应消息。

pic_photo_or_album,方式和pic_weixin 一样,先推送菜单事件,再推送图片消息

<span><</span><span>xml</span><span>></span>
    <span><</span><span>ToUserName</span><span>></span><span><![CDATA[</span><span>gh_82479813ed64</span><span>]]></span><span></</span><span>ToUserName</span><span>></span>
    <span><</span><span>FromUserName</span><span>></span><span><![CDATA[</span><span>ojpX_jig-gyi3_Q9fHXQ4rdHniQs</span><span>]]></span><span></</span><span>FromUserName</span><span>></span>
    <span><</span><span>CreateTime</span><span>></span>1412075614<span></</span><span>CreateTime</span><span>></span>
    <span><</span><span>MsgType</span><span>></span><span><![CDATA[</span><span>event</span><span>]]></span><span></</span><span>MsgType</span><span>></span>
    <span><</span><span>Event</span><span>></span><span><![CDATA[</span><span>pic_photo_or_album</span><span>]]></span><span></</span><span>Event</span><span>></span>
    <span><</span><span>EventKey</span><span>></span><span><![CDATA[</span><span>rselfmenu_1_1</span><span>]]></span><span></</span><span>EventKey</span><span>></span>
    <span><</span><span>SendPicsInfo</span><span>></span>
        <span><</span><span>Count</span><span>></span>1<span></</span><span>Count</span><span>></span>
        <span><</span><span>PicList</span><span>></span>
            <span><</span><span>item</span><span>></span>
                <span><</span><span>PicMd5Sum</span><span>></span><span><![CDATA[</span><span>58f4989164b2a432889e64fa81632152</span><span>]]></span><span></</span><span>PicMd5Sum</span><span>></span>
            <span></</span><span>item</span><span>></span>
        <span></</span><span>PicList</span><span>></span>
        <span><</span><span>EventKey</span><span>></span><span><![CDATA[</span><span>rselfmenu_1_1</span><span>]]></span><span></</span><span>EventKey</span><span>></span>
    <span></</span><span>SendPicsInfo</span><span>></span>
<span></</span><span>xml</span><span>></span>
<span><</span><span>xml</span><span>></span>
    <span><</span><span>ToUserName</span><span>></span><span><![CDATA[</span><span>gh_82479813ed64</span><span>]]></span><span></</span><span>ToUserName</span><span>></span>
    <span><</span><span>FromUserName</span><span>></span><span><![CDATA[</span><span>ojpX_jig-gyi3_Q9fHXQ4rdHniQs</span><span>]]></span><span></</span><span>FromUserName</span><span>></span>
    <span><</span><span>CreateTime</span><span>></span>1412075618<span></</span><span>CreateTime</span><span>></span>
    <span><</span><span>MsgType</span><span>></span><span><![CDATA[</span><span>image</span><span>]]></span><span></</span><span>MsgType</span><span>></span>
    <span><</span><span>PicUrl</span><span>></span><span><![CDATA[</span><span>http://mmbiz.qpic.cn/mmbiz/qOTIrRtMKFxZQo3cQ6vYxmfteo0fw2Y0fwSdF54rribCj9zqDG0wVDsiasKuUC8gskbuZmX43a1hs9esySIvmrqA/0</span><span>]]></span><span></</span><span>PicUrl</span><span>></span>
    <span><</span><span>MsgId</span><span>></span>6064818598989675467<span></</span><span>MsgId</span><span>></span>
    <span><</span><span>MediaId</span><span>></span><span><![CDATA[</span><span>Jh7Bsjaodmz-Dc_Hdz_wRzY3RiFxNvA4JHpUWRNRCIgps19ANsDFIOYOUV1dIVYV</span><span>]]></span><span></</span><span>MediaId</span><span>></span>
<span></</span><span>xml</span><span>></span>

 pic_sysphoto 这个后台其实收不到该菜单的消息,点击它后,调用的是手机里面的照相机功能,而照相以后再发过来时,就收到的是一个图片消息了

<span><</span><span>xml</span><span>></span>
    <span><</span><span>ToUserName</span><span>></span><span><![CDATA[</span><span>gh_82479813ed64</span><span>]]></span><span></</span><span>ToUserName</span><span>></span>
    <span><</span><span>FromUserName</span><span>></span><span><![CDATA[</span><span>ojpX_jig-gyi3_Q9fHXQ4rdHniQs</span><span>]]></span><span></</span><span>FromUserName</span><span>></span>
    <span><</span><span>CreateTime</span><span>></span>1412135923<span></</span><span>CreateTime</span><span>></span>
    <span><</span><span>MsgType</span><span>></span><span><![CDATA[</span><span>image</span><span>]]></span><span></</span><span>MsgType</span><span>></span>
    <span><</span><span>PicUrl</span><span>></span><span><![CDATA[</span><span>http://mmbiz.qpic.cn/mmbiz/qOTIrRtMKFxGzYCchrNiczZ9aCd1fgCEWbicHGvmaz1d7VZOSMqoLB4RL69rK2Fos6fSM4FJRkLtiajpe32ibkicw1A/0</span><span>]]></span><span></</span><span>PicUrl</span><span>></span>
    <span><</span><span>MsgId</span><span>></span>6065077606992462276<span></</span><span>MsgId</span><span>></span>
    <span><</span><span>MediaId</span><span>></span><span><![CDATA[</span><span>PqRRUPLhMc27EG5F4cCtTozBsin7SY8kPRRuAF-CwPl5MzR5ewE5oji0FhGTDl6_</span><span>]]></span><span></</span><span>MediaId</span><span>></span>
<span></</span><span>xml</span><span>></span>

location_select 将会调起发送位置功能,菜单的响应用户收不到,在用户发送位置之后,会再推送一个地理位置消息功能给用户

<span><</span><span>xml</span><span>></span>
    <span><</span><span>ToUserName</span><span>></span><span><![CDATA[</span><span>gh_82479813ed64</span><span>]]></span><span></</span><span>ToUserName</span><span>></span>
    <span><</span><span>FromUserName</span><span>></span><span><![CDATA[</span><span>ojpX_jig-gyi3_Q9fHXQ4rdHniQs</span><span>]]></span><span></</span><span>FromUserName</span><span>></span>
    <span><</span><span>CreateTime</span><span>></span>1412075681<span></</span><span>CreateTime</span><span>></span>
    <span><</span><span>MsgType</span><span>></span><span><![CDATA[</span><span>event</span><span>]]></span><span></</span><span>MsgType</span><span>></span>
    <span><</span><span>Event</span><span>></span><span><![CDATA[</span><span>location_select</span><span>]]></span><span></</span><span>Event</span><span>></span>
    <span><</span><span>EventKey</span><span>></span><span><![CDATA[</span><span>rselfmenu_2_0</span><span>]]></span><span></</span><span>EventKey</span><span>></span>
    <span><</span><span>SendLocationInfo</span><span>></span>
        <span><</span><span>Location_X</span><span>></span><span><![CDATA[</span><span>22.538145</span><span>]]></span><span></</span><span>Location_X</span><span>></span>
        <span><</span><span>Location_Y</span><span>></span><span><![CDATA[</span><span>113.952298</span><span>]]></span><span></</span><span>Location_Y</span><span>></span>
        <span><</span><span>Scale</span><span>></span><span><![CDATA[</span><span>13</span><span>]]></span><span></</span><span>Scale</span><span>></span>
        <span><</span><span>Label</span><span>></span><span><![CDATA[</span><span>深圳市南山区高新南一道9号</span><span>]]></span><span></</span><span>Label</span><span>></span>
        <span><</span><span>Poiname</span><span>></span><span><![CDATA[]]></span><span></</span><span>Poiname</span><span>></span>
        <span><</span><span>EventKey</span><span>></span><span><![CDATA[</span><span>rselfmenu_2_0</span><span>]]></span><span></</span><span>EventKey</span><span>></span>
    <span></</span><span>SendLocationInfo</span><span>></span>
<span></</span><span>xml</span><span>></span>
<span><</span><span>xml</span><span>></span>
    <span><</span><span>ToUserName</span><span>></span><span><![CDATA[</span><span>gh_82479813ed64</span><span>]]></span><span></</span><span>ToUserName</span><span>></span>
    <span><</span><span>FromUserName</span><span>></span><span><![CDATA[</span><span>ojpX_jig-gyi3_Q9fHXQ4rdHniQs</span><span>]]></span><span></</span><span>FromUserName</span><span>></span>
    <span><</span><span>CreateTime</span><span>></span>1412075681<span></</span><span>CreateTime</span><span>></span>
    <span><</span><span>MsgType</span><span>></span><span><![CDATA[</span><span>location</span><span>]]></span><span></</span><span>MsgType</span><span>></span>
    <span><</span><span>Location_X</span><span>></span>22.538145<span></</span><span>Location_X</span><span>></span>
    <span><</span><span>Location_Y</span><span>></span>113.952298<span></</span><span>Location_Y</span><span>></span>
    <span><</span><span>Scale</span><span>></span>13<span></</span><span>Scale</span><span>></span>
    <span><</span><span>Label</span><span>></span><span><![CDATA[</span><span>深圳市南山区高新南一道9号飞亚达科技大厦方倍工作室</span><span>]]></span><span></</span><span>Label</span><span>></span>
    <span><</span><span>MsgId</span><span>></span>6064818869572615123<span></</span><span>MsgId</span><span>></span>
<span></</span><span>xml</span><span>></span>

 

四、使用场景

4.1 产品二维码检测真伪

 使用scancode_waitmsg事件,可以获得扫描结果,再与现有结果进行比对,从而可以达到检测二维码真实性的功能。

一个检测代码如下所示:

<span>1</span> <span>case</span> "scancode_waitmsg":
<span>2</span>     <span>if</span> (<span>$object</span>->ScanCodeInfo->ScanResult == "http://mm.wanggou.com/item/jd2.shtml?sku=11447844"<span>){
</span><span>3</span>         <span>$content</span> = <span>array</span><span>();
</span><span>4</span>         <span>$content</span>[] = <span>array</span>("Title"=>"该产品检测结果为正品", "Description"=>"书名:微信公众平台开发最佳实践\n定价:¥69.00\n作者:方倍工作室\n\n点击&ldquo;查看全文&rdquo;,使用微信支付在线购买", "PicUrl"=>"http://images.cnitblog.com/i/340216/201404/301756448922305.jpg", "Url" =>"http://mm.wanggou.com/item/jd2.shtml?sku=11447844"<span>);
</span><span>5</span>     }<span>else</span><span>{
</span><span>6</span>         <span>$content</span> = "扫码带提示:类型 ".<span>$object</span>->ScanCodeInfo->ScanType." 结果:".<span>$object</span>->ScanCodeInfo-><span>ScanResult;
</span><span>7</span> <span>    }
</span><span>8</span>     <span>break</span>;

当用户使用scancode_waitmsg菜单扫描以下二维码时,将出现检测结果,结果为真时,还可以再进一步,让用户进入购买

4.2 快递进度查询

基于上面同样的原理,可以实现扫描快递条形码,就查询快递进度的功能。

一个快递的单号如下

扫描以后,返回结果为 

扫码带提示:类型 qrcode/CODE_39 结果:762480955342

正确识别了其中的快递单号

4.3 导航/附近/地图

location_select事件比之前的直接发送地理位置消息更少了一步,比如下面的

微信公众平台怎做自定义菜单

WeChat has launched a custom menu, which has made many people have high expectations, but I think this is not necessary for public accounts. Nowadays, form is more important than practicality. Most users are actually used to getting content through input. There is really no need to be too obsessed with it. The use of customized menus and good service are fundamental. Recently, WeChat quietly launched a custom menu for internal testing, which once again attracted the attention of countless people. No matter who it was, they were doing a few things on the 19th. One was to fill out the form to apply for internal testing, and the other was to study the custom menu interface. Documents, the third is to write various analysis articles on custom menus, and the fourth is to rely on various connections to get the qualification for internal testing as soon as possible. Ztalk also has to take the company information to apply, but because it is a self-media, it is probably not available, so it will be a bit disappointing, but calm down
...Expand
WeChat launches a custom menu, which makes many people happy I have high expectations, but I think this is not necessary for public accounts. Nowadays, form is more important than practicality. Most users are actually used to getting content through input. There is really no need to be too obsessed with using custom menus. Good service is fundamental. Recently, WeChat quietly launched a custom menu for internal testing, which once again attracted the attention of countless people. No matter who it was, they were doing a few things on the 19th. One was to fill out the form to apply for internal testing, and the other was to study the custom menu interface. Documents, the third is to write various analysis articles on custom menus, and the fourth is to rely on various connections to get the qualification for internal testing as soon as possible. Ztalk also has to take the company information to apply, but because it is a self-media, it is probably not available, so I will be a little disappointed, but I will not be depressed if I calm down and think about it clearly. In fact, so what if you get this interface? Do public accounts really need to customize menus? What exactly is a custom menu? Friends, what is the essence of subscribing to "ZTalk"? What exactly is a custom menu? Most people have great expectations for custom menus, thinking that anything new officially launched must be a powerful marketing tool, but in fact it is just a shortcut key to focus on functions, and not everyone needs it. I remember an article once mentioned that the user service acquisition path for WeChat public accounts is too long. Users must first find the public account to enter, then click on an article or obtain the article through query and click to enter the WeChat article template, and then click to read the original text To finally reach the service, that is, the user may have to go through three to four steps or even more to get what he wants. Of course, having a custom menu can shorten this process. For some companies, the content that needs to be displayed prominently can be placed directly on the menu. For example, an e-commerce seller can set up a menu bar to place new products on the market, and then set up a menu bar to place group purchase discounts. Users can directly enter the purchase page after clicking. You can also set up a menu bar to place product categories to go directly to each product category. For example, a hotel chain can set up a menu to display the latest promotions, another menu to display hotel introductions and room displays, and another menu bar to send geographical locations and query nearby hotels. For example, in a department store, you can set up a menu to display the latest discounts and promotions, another menu to display product introductions at the floor counter, and another menu for information services such as store address, telephone number, and membership services. The main function of the custom menu is to allow users to reduce the learning cost of information acquisition, make the company's public account more intuitive, and make information transmission easier. In fact, with this menu, you can treat the WeChat public account as a website. Users It can be used like browsing the web. Custom menu is not a necessary function for public accounts. First of all, before this custom menu, public accounts could already complete these functions very well. By designing a friendly, clear and interactive welcome word and usage help, and using keyword replies to display the corresponding content to users in the form of text or multiple graphics, now with a custom menu, it is nothing more than paying attention to what is in the welcome word. A bunch of interactive guidance has been replaced. Of course, there will be new interfaces for custom menus in the future, but for now, just link pointing is not very useful. Of course, it will be very useful for H5 pages in games or e-commerce. Secondly, the custom menu will cover the input box of the public account. When the user needs to interact by inputting text or voice, he has to click the button to switch, which will be an extra step. Therefore, for some public accounts that focus on content browsing information query, the custom menu automatically Defining the menu is useful, but it is better not to have a public account that focuses on user interaction and services. Finally, the custom menu currently needs to be developed through the interface before it can be used. Originally, this menu will be made into the backend... The rest of the full text >>

Does WeChat public platform require WeChat ID authentication to create a custom menu in the development platform?

Judging from the current situation, both service accounts and subscription accounts can apply for their own custom menus after certification. However, some advanced development functions can only be reflected on service accounts, and subscription accounts cannot yet be implemented.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/887683.htmlTechArticleWeChat public platform development (104) Scan the custom menu, send pictures, and send location, 104 scan Keywords: WeChat public platform custom menu, scan and send pictures, send location for...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
微信文件多久过期微信文件多久过期Nov 21, 2022 pm 02:12 PM

微信文件的过期时间需要根据情况来判断:1、如果发送的文件没有打开过,则在72小时以后微信系统会自动清理掉,即过了三天文件就会过期;2、如果已经查看了微信文件,但是并没有下载(当然已经下载的文件也是一样的),那么文件是可以保留180天的,在这180天以内随时都可以去下载。

微信拉黑和删除有什么区别微信拉黑和删除有什么区别Oct 18, 2022 am 11:29 AM

区别:1、拉黑后对话框从主页消失,但是聊天记录还在;删除后聊天记录全部消失不见了。2、拉黑后还能发给他,但是收不到他的消息;删除后不能发信息了。3、拉黑后双方都不可见彼此的朋友圈;删除对方以后,你看不到对方的朋友圈了,对方是否能看到你的,取决于设置(允许陌生人查看十张照片)与否,如果设置则可以看到朋友圈。

支持微信付款的购物平台有哪些支持微信付款的购物平台有哪些Nov 02, 2022 pm 02:44 PM

支持微信付款的购物平台有:1、京东,是中国的综合网络零售商;2、唯品会,是一家在线销售品牌折扣商品的互联网公司;3、拼多多,是社交新电商领导者,更懂消费者的购物平台;4、京喜,是京东旗下生活消费商城;5、蘑菇街,一个电子商务网站;6、聚美优品,是一家以销售化妆品为主的时尚购物网站;7、微店,是一个云推广电子商务平台;8、考拉海购,是一个跨境海淘业务为主的会员电商平台。

微信怎么查看ip地址微信怎么查看ip地址May 31, 2023 am 09:16 AM

微信查看ip地址的方法:1、登录电脑版微信,右键点击屏幕下方的任务栏,点击“任务管理器”;2、弹出任务管理器时,点击左下角的“详细信息”;3、任务管理器进入“性能”选项,点击“打开资源监视器”;4、选择“网络”,勾选微信进程“Wechat.exe”;5、点击下面的“TCP连接”即可监视微信网络IP相关情况,发送消息得到回复就会显示他人的IP地址。

微信可以绑别人的银行卡号么微信可以绑别人的银行卡号么Mar 14, 2023 pm 04:53 PM

可以。未经过实名认证的微信号,可以绑定他人的银行卡,但在绑定过程中需要提供银行卡的开户人姓名、开户行地址、开户时预留的联系方式及银行卡支付密码;已通过实名认证的微信号,无法绑定他人银行卡,只能添加使用自己身份证办理的银行卡。

一个身份证只能绑定一个微信吗一个身份证只能绑定一个微信吗Mar 02, 2023 pm 01:50 PM

不是,一个身份证能绑定5个微信。按照微信当前规定,一个身份证可以实名认证5个微信号;如果已经实名认证了5个微信账号,但是还想要继续实名,就要把已经实名认证的一些不用的微信号清除以后,才可以再实名认证新的微信号。

财付通是微信还是支付宝财付通是微信还是支付宝Oct 18, 2022 pm 02:35 PM

财付通是微信,是腾讯公司旗下的第三方支付平台,其核心业务是协助在互联网上进行交易的双方完成支付和收款,其使用方式是:1、进行账户注册及登录;2、进行账户充值;3、根据需求设置快捷支付;4、通过打开微信支付或QQ钱包查询交易账单。

电脑微信打字为什么打一个少一个电脑微信打字为什么打一个少一个Mar 28, 2023 pm 03:43 PM

电脑微信打字打一个少一个是因为开启了改写状态,其解决办法:1、打开电脑微信;2、在微信聊天窗口输入对话文字内容;3、找到并按下键盘上的Insert键即可正常输入文字内容。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),