微信之定义菜单

xiaoxiao2021-02-28  124

<?php $token = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=根据(https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET)生成自己的token"; $str = file_get_contents($token); $access_token = json_decode($str,true); $token1 = $access_token['access_token']; $url ="https://api.weixin.qq.com/cgi-bin/menu/create?access_token=$token1"; $post_data = ' { "button":[ { "name":"涂涂旅行", "sub_button":[ { "type":"view", "name":"旅游景点介绍", "url":"http://www.sove.xin" }, { "type":"view", "name":"周末旅行", "url":"http://www.sove.xin" }, { "type":"click", "name":"优惠活动", "key":"V1001_GOOD" }] }, { "type":"view", "name":"在线订票", "url":"http://www.sove.xin" }, { "type":"view", "name":"会员中心", "url":"http://www.sove.xin" } ] }'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2); // post数据 curl_setopt($ch, CURLOPT_POST, 1); // post的变量 curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); $output = curl_exec($ch); curl_close($ch); //打印获得的数据 print_r($output); ?>
转载请注明原文地址: https://www.6miu.com/read-28125.html

最新回复(0)