PHP custom menu for micro-credit development

Source: Internet
Author: User
Tags php framework
This article mainly for you to introduce the PHP development of the custom menu implementation code, with a certain reference value, interested in small partners can refer to

There is a conflict between the edit mode and the development mode. So after we enable the public number development model, those menus are not visible. But now the personal subscription number is not available in the Advanced developer mode, such as a custom menu, but we can still test the test number, and then move the code to the service number.

The custom types include the following:

1. Click: Push Event
• After the user clicks the Click type button, the server pushes the message type to the developer via the message interface (refer to the Message Interface Guide), and with the key value that the developer fills in the button, the developer can interact with the user through a custom key value;

2. View: Jump URL
• After the user clicks on the View Type button, the client will open the URL of the webpage that the developer fills in the button, which can be combined with the user's basic information interface to obtain the basic information of the user.

3, Scancode_push: Sweep code Push event
• After the user clicks on the button, the client will adjust the sweep tool to display the scan result (if it is URL, will enter the URL), and will pass the result of the sweep code to the developer, the developer can send the message.

4, Scancode_waitmsg: sweep the code to push the event and pop-up "message received in" Prompt box
• After the user taps the button, the client will pick up the sweep tool, complete the sweep code operation, pass the result of the sweep code to the developer, and then close the Sweep tool, then pop up the "message receive in" Prompt box, then you may receive the message from the developer.

The custom types include the following:

5, Pic_sysphoto: pop-up system photo map user Click the button, the client will adjust the system camera, after the photo operation, will be taken photos
Send it to the developer, push the event to the developer, and close the system camera, and you may receive a message from the developer.

6, Pic_photo_or_album: pop-up photos or photo albums when the user clicks the button, the client will pop up a selector for the user to choose "Take photos" or "Choose from a mobile album." The user chooses to go through the other two processes.

7, Pic_weixin: Pop-up album after the user click the button, the client will be the album, after the selection operation, the selected photos sent
Send the server to the developer, push the event to the developer, and close the album, and you may receive a message from the developer.

Provide the code, just upload the code to the server, re-focus on the public number can see the development mode of the custom menu

$appid = ' AppID of the public number '; $appsecret = ' Appsecret of the public number '; $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret=$ Appsecret "; $output = Https_request ($url); $jsoninfo = Json_decode ($output, true); $access _token = $jsoninfo ["Access_token"]; $jsonmenu = ' {' button ': [{' name ': ' School system ', ' Sub_button ': [{' Type ': ' Click ', ' Name ': ' Curriculum ', ' Ke Y ":" Curriculum "}, {" Type ":" click "," Name ":" Personal Information "," Key ":" Personal Information "}, {" Type ":" click "," N     Ame ":" Normal score "," Key ":" Normal Score "}, {" Type ":" click "," Name ":" Reward and Punishment record "," Key ":" Reward and Punishment Record "}]}, {      "Name": "Technology sharing", "Sub_button": [{"Type": "click", "Name": "Mobile Web Development", "key": "Mobile Web Development"}, {      "Type": "click", "Name": "Java EE framework", "Key": "Java EE framework"}, {"Type": "click", "Name": "Android Development",    "Key": "Android Development"}, {"Type": "click", "Name": "PHP Framework", "Key": "PHP Framework"}]},{"name": "Technical Support", "Sub_button": [{"Type": "click", "Name": "Online customer service", "key": "Online Customer Service"}, { "Type": "click", "Name": "Technology sharing", "key": "Technology Sharing"}, {"Type": "View", "name": "Weather Forecast", "url"    : "Http://m.hao123.com/a/tianqi"}]}]} ';  Create a menu implementation $url = ' https://api.weixin.qq.com/cgi-bin/menu/create?access_token= '. $access _token;  $result = Https_request ($url, $jsonmenu);  Var_dump ($result);   function Https_request ($url, $data = null) {$curl = Curl_init ();   curl_setopt ($curl, Curlopt_url, $url);   curl_setopt ($curl, curlopt_ssl_verifypeer,0);   curl_setopt ($curl, curlopt_ssl_verifyhost,0);    if (!empty ($data)) {curl_setopt ($curl, curlopt_post,1);   curl_setopt ($curl, Curlopt_postfields, $data);   } curl_setopt ($curl, curlopt_returntransfer,1);   $output = curl_exec ($curl);   Curl_close ($curl);  return $output; }

The above is the whole content of this article, I hope that everyone's study has helped.


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.