PHP version of micro-letter Implementation Public Number menu Add delete operation

Source: Internet
Author: User
Tags json

To debug the new menu function in the quickest way, the Debug method is used to generate the new menu. Please parameter micro-Letter tutorial 2 of the Wechat-json class. After importing the file, we use the Debug method to generate a new menu:
if (Isset ($ARGC) && $argc >= 1 && $argv [0] = = __file__) {
$client = new Wechatjson (Array (
wechatjson::app_id => ' wx78acfe8023sfsd4d51 ',
Wechatjson::app_secret => ' 9ba3476db1ffsfsf512e0b22f630fa ',
));

$res = $client->call ('/menu/create ', Array (
' button ' => array (
Array (
' Name ' => ' Sweep code ',
' Sub_button ' => Array (
Array
' Name ' => ' sweep code not prompt ',
' Type ' => ' Scancode_push ',
' Key ' => ' Rselfmenu_0_0 ',
' Sub_button ' =>array ()
),
Array
' Name ' => ' sweep code with hints ',
' Type ' => ' scancode_waitmsg ',
' Key ' => ' rselfmenu_0_1 ',
' Sub_button ' =>array ()
),
),
),
Array
' Name ' => ',
' Sub_button ' => Array (
Array
' Name ' => ' system photo-drawing ',
' Type ' => ' Pic_sysphoto ',
' Key ' => ' Rselfmenu_1_0 ',
' Sub_button ' => Array ()
),
Array
' Name ' => ' photo or photo album ',
' Type ' => ' Pic_photo_or_album ',
' Key ' => ' rselfmenu_1_1 ',
' Sub_button ' => Array ()
),
Array
' Name ' => ' micro-letter album Hair Map ',
' Type ' => ' pic_weixin ',
' Key ' => ' rselfmenu_1_2 ',
' Sub_button ' => Array ()
),
)
),
Array
' Name ' => ' send Location ',
' Type ' => ' Location_select ',
' Key ' => ' rselfmenu_2_0 '
)
)
)
, Wechatjson::json);
if (! $res) {
Var_dump ($client->_error);
}
Var_export ($res);
}

After implementation, the cancellation attention again attention, lets the new menu take effect!
Effect Chart:



The test results are as follows:
Scancode_push Event:
Array (
' Tousername ' => ' gh_e2a2b3bd35ff ',
' Fromusername ' => ' On0evjnystxkcsaacamycpmzdmwa ',
' Createtime ' => ' 1411629272 ',
' Msgtype ' => ' event ',
' Event ' => ' Scancode_push ',
' Eventkey ' => ' 6 ',
' Scancodeinfo ' =>
Simplexmlelement::__set_state Array (
' ScanType ' => ' QRCode ',
' Scanresult ' => ' http://www.baidu.com/',
)),
Array (
' Tousername ' => ' gh_e2a2b3bd35ff ',
' Fromusername ' => ' On0evjnystxkcsaacamycpmzdmwa ',
' Createtime ' => ' 1411629475 ',
' Msgtype ' => ' event ',
' Event ' => ' Scancode_push ',
' Eventkey ' => ' 6 ',
' Scancodeinfo ' =>
Simplexmlelement::__set_state Array (
' ScanType ' => ' qrcode/ean_13 ',
' Scanresult ' => ' 6925082946487 ',
' Eventkey ' =>
Simplexmlelement::__set_state Array (
)),
)),
)






The above is the click on the menu "Scan code does not prompt" after the log, there are two kinds of situations, the first is that if you sweep a two-dimensional code that is a URL, it jumps to the Web page (note includes the two-dimensional code generated by the service number), and the second is that if you sweep a barcode, you jump to the details of the product. It is commonly used to check prices.

Scancode_waitmsg Event:
Array (
' Tousername ' => ' gh_e2a2b3bd35ff ',
' Fromusername ' => ' On0evjnystxkcsaacamycpmzdmwa ',
' Createtime ' => ' 1411629302 ',
' Msgtype ' => ' event ',
' Event ' => ' scancode_waitmsg ',
' Eventkey ' => ' 6 ',
' Scancodeinfo ' =>
Simplexmlelement::__set_state Array (
' ScanType ' => ' QRCode ',
' Scanresult ' => ' http://www.111cn.net/',
)),


Above is the click of the menu "sweep code hint" after the log, push XML is similar to Scancode_push, but it will not jump to the Web site or merchandise information. Bo advocate that this is conducive to the background to obtain Scancodeinfo information to further deal with! For example, you customize two-dimensional code information, and then intercept the processing. A parameter two-dimensional code similar to the original service number.
Note that the above two menu scanning events and micro-app sweep sweep, there is a difference. Concrete you see the event can see, scan event!
Pic_sysphoto events, Pic_photo_or_album events, and Pic_weixin events
Array (
' Tousername ' => ' gh_e2a2b3bd35ff ',
' Fromusername ' => ' On0evjnystxkcsaacamycpmzdmwa ',
' Createtime ' => ' 1411627313 ',
' Msgtype ' => ' image ',
' Picurl ' => ' http://mmbiz.qpic.cn/mmbiz/ L8zbjclqnfvez4dne4mgqqgr8xuhk4khek3icghu6a4bftxnp2oeicr5vabvja10w4myooeia4udqict5fdtaadhyg/0 ',
' MsgId ' => ' 6062893143676022221 ',
' MediaID ' => ' I7HYOLSXBUCAC7Z9ELX4WPBQQQ37-HR0EL5W-FRPFD5WCDBC7X46DPO6HL7ZMFGD ',
)






The above is the point of "hair map", three submenus selected or photographed, the log after the map information, from the figure we see the event is pushed over the image, other information, I believe we all know what is not explained.
Location_select Event:
Array (
' Tousername ' => ' gh_e2a2b3bd35ff ',
' Fromusername ' => ' On0evjnystxkcsaacamycpmzdmwa ',
' Createtime ' => ' 1411627424 ',
' Msgtype ' => ' event ',
' Event ' => ' Location_select ',
' Eventkey ' => ' 6 ',
' Sendlocationinfo ' =>
Simplexmlelement::__set_state Array (
' location_x ' => ' 23 ',
' location_y ' => ' 113 ',
' Scale ' => ' 15 ',
' Label ' =>
Simplexmlelement::__set_state Array (
)),
' Poiname ' =>
Simplexmlelement::__set_state Array (
)),
)),
)






The above is click on the menu "send Location" after the log, we can see that the event is location_select, not like the hair map to become image, the most valuable information we want to take the Sendlocationinfo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.