PHP WeChat public number custom menu

Source: Internet
Author: User
This article mainly introduces the PHP version of the public number of custom menu, has a certain reference value, now share to everyone, the need for friends can refer to

<?php//id key $appid = "wx5502a933452cecf0"; $appsecret = "c7fd97ec7ce4ec3c5f2766b89d97512c"; $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); Returns an array
7200var_dump ($jsoninfo);
$access _token = $jsoninfo ["Access_token"];//d defines the format of the menu $jsonmenu = ' {' button ': [{' name ': ' See Popular Science ', "Sub_button": [{"Type": "View", "name": "Expert lecture hall", "url": "Http://m.h Ao123.com/a/tianqi "}, {" Type ":" View "," name ":" Sterile ","                URL ":" Http://m.hao123.com/a/tianqi "}, {" Type ":" View "," name ":" IVF ", "url": "Http://m.hao123.com/a/tianqi"}]}, {"name": "Ask Doctor", "Sub_ Button ": [{" Type ":" View "," name ":" Portal "," url ":" http://m.hao123.com/               A/tianqi "}]}, {" name ":" Find Service "," Sub_button ": [{            "Type": "View", "name": "Mall Entry", "url": "Http://m.hao123.com/a/tianqi"         },            {      "Type": "View", "name": "Overseas Doctor", "url": "Http://m.hao123.com/a/tianqi"},            {"Type": "View", "name": "Hospital Recommendation", "url": "Http://m.hao123.com/a/tianqi" }]}]} '; $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=". $access _token; $resu lt = 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, FALSE);    curl_setopt ($curl, Curlopt_ssl_verifyhost, FALSE);    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;}? >
Array (2) {  ["Access_token"]=&gt;  String (156) "5_wfmite_skjx6zyy4jivg6ayjjuamh2qnxatrsrxvrkmgoqxpgihlkhxnb4ah6atrjvodea_ Oeoncr1oob0alyyw7uhibuqcvg2p0h-6ksabxnbnyxherlbf49z-pac_z7gp2p-pqaey-gr_zmpcdadawzm "  [" expires_in "]=& gt;  Int (7200)}string (+) "{" Errcode ": 0," errmsg ":" OK "}" generated by the number of groups, I follow the document step-by-step  write rough, can run directly

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.