您好,欢迎访问一九零五行业门户网

微信自定义菜单的处理开发示例_PHP教程

微信自定义菜单的处理开发示例 自定义菜单的创建
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
62
63
64
define(appid, 您的appid);
define(appsecret, 您的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); //获取文件内容或获取网络请求的内容
//echo $res;
$result = json_decode($res, true); //接受一个 json 格式的字符串并且把它转换为 php 变量
$access_token = $result['access_token'];
define(access_token, $access_token); //将access_token定义为常量,便于使用.
$make_menu_url = https://api.weixin.qq.com/cgi-bin/menu/create?access_token= . access_token;
$menudata = ' {
button:[
{
type:click,
name:今日歌曲,
key:v1001_today_music
},
{
name:菜单,
sub_button:[
{
type:view,
name:搜索,
url:http://www.soso.com/
},
{
type:view,
name:视频,
url:http://v.qq.com/
},
{
type:click,
name:赞一下我们,
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);
//判读执行过程中是否有错误,有则发送数据错误报告.
if (curl_errno($ch)) {
echo 'error' . curl_error($ch); //用户检查php运行环境中的curl模块开启情况.
}
curl_close($ch);
print_r($info); //查看post提交到微信服务器后,返回的数据.
自定义菜单的获取
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
define(appid, 您的appid);
define(appsecret, 您的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); //获取文件内容或获取网络请求的内容
$result = json_decode($res, true); //接受一个 json 格式的字符串并且把它转换为 php 变量
$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;
自定义菜单的删除
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
define(appid, 您的appid);
define(appsecret, 您的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); //获取文件内容或获取网络请求的内容
$result = json_decode($res, true); //接受一个 json 格式的字符串并且把它转换为 php 变量
$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;
http://www.bkjia.com/phpjc/985145.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/985145.htmltecharticle微信自定义菜单的处理开发示例 自定义菜单的创建 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 4...
其它类似信息

推荐信息