Example of processing and development of micro-letter custom Menus

Source: Internet
Author: User
Tags json php define

  Customize Menu Creation

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 The <?php   define ("APPID", "Your APPID"); Define ("Appsecret", "Your appsec RET ");   $token _access_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=". APPID. "&secret=". Appsecret; $res = file_get_contents ($token _access_url); Gets the contents of the file or gets the content of the network request//echo $res; $result = Json_decode ($res, true); Accepts a JSON-formatted string and converts it to a PHP variable $access _token = $result [' Access_token '];   Define ("Access_token", $access _token); Define Access_token as constants for ease of use.   $make _menu_url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=". Access_token;   $menuData = ' {button ': [{' Type ': ' Click ', ' name ': ' Today's song ', ' Key ': ' V1001_today_music '}, {' Name ': ' Menu ', ' Sub_buTton ': [{' type ': ' View ', ' name ': ' Search ', ' url ': ' http://www.soso.com/'}, {' type ': ' View ', ' name ': ' Video ', ' url ': ' http:// v.qq.com/"}, {" Type ":" click "," Name ":" Praise Us "," Key ":" V1001_good "}}]} ';   $ch = Curl_init ();   curl_setopt ($ch, Curlopt_url, $make _menu_url); curl_setopt ($ch, Curlopt_customrequest, "POST"); curl_setopt ($ch, Curlopt_ssl_verifypeer, FALSE); curl_setopt ($ch, Curlopt_ssl_verifyhost, FALSE); curl_setopt ($ch, Curlopt_useragent, "mozilla/5.0" (compatible; MSIE 6.0; Windows NT 5.1. NET CLR 1.1.4322); curl_setopt ($ch, curlopt_followlocation, 1); curl_setopt ($ch, Curlopt_autoreferer, 1); curl_setopt ($ch, Curlopt_postfields, $menuData); curl_setopt ($ch, Curlopt_returntransfer, TRUE);   $info = curl_exec ($ch);  //interpretation of errors in the implementation process, there is a data error report sent. if (Curl_errno ($ch)) {echo ' Error '. Curl_error ($ch);//user checks the Curl module in the PHP operating environment.}   Curl_close ($ch); Print_r ($info); View the data returned after post is submitted to the micro-trust server.

Access to custom menus

1 2 3 4, 5 6 7 8 9 10 11 12 13 14 15 <?php define ("APPID", "Your APPID");   Define ("Appsecret", "Your Appsecret"); $token _access_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=". APPID. "&secret=". Appsecret; $res = file_get_contents ($token _access_url); Gets the contents of the file or gets the content of the network request $result = Json_decode ($res, true);   Accepts a JSON-formatted string and converts it to a PHP variable $access _token = $result [' Access_token ']; $make _menu_url = "https://api.weixin.qq.com/cgi-bin/menu/get?access_token=".   $access _token;   $menu _json = file_get_contents ($make _menu_url); echo $menu _json;

Customizing the deletion of menus

1 2 3 4 5 6 7 8 9/ <?php   define ("APPID", "Your APPID"); Define ("Appsecret", "Your Appsecret");   $token _access_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=". APPID. "&secret=". Appsecret; $res = file_get_contents ($token _access_url); Gets the contents of the file or gets the content of the network request $result = Json_decode ($res, true); Accepts a JSON-formatted string and converts it to a PHP variable $access _token = $result [' Access_token '];   $make _menu_url = "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=". $access _token;   $menu _json = file_get_contents ($make _menu_url);   Echo $menu _json;

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.