新浪粉丝服务平台教程三:自定义菜单

来源:互联网 发布:ubuntu彻底删除软件 编辑:程序博客网 时间:2024/05/22 04:59

菜单创建的方法为POST

curl "https://m.api.weibo.com/2/messages/menu/create.json?access_token=ACCESS_TOKEN" -d 'menus={ }'

基本和微信类似,写的有点莫名其妙,access_token就是接口验证获得的。菜单也是两类,view和click

<?php//创建菜单$secret="*****";$url = "https://m.api.weibo.com/2/messages/menu/create.json?access_token={$secret}";$post='{    "button": [        {            "type": "view",            "name": "粉丝平台教程",            "url": "http://xx.html"        },{            "type": "view",            "name": "百度",            "url": "http://www.baidu.cn"        },{            "type": "click",            "name": "联系方式",            "key": "phone"        }    ]}';$b="menus={$post}";$ch = curl_init();//新建curlcurl_setopt($ch, CURLOPT_URL, $url);//url  curl_setopt($ch, CURLOPT_POST, 1);  //postcurl_setopt($ch, CURLOPT_POSTFIELDS, $b);//post内容  curl_exec($ch); //输出   curl_close($ch); ?>


删除菜单

<?php//删除菜单$secret="*";$url = "https://m.api.weibo.com/2/messages/menu/delete.json";$ch = curl_init();//新建curl$post="access_token={$secret}";curl_setopt($ch, CURLOPT_URL, $url);//url  curl_setopt($ch, CURLOPT_POST, 1);  //postcurl_setopt($ch, CURLOPT_POSTFIELDS, $post);//post内容  curl_exec($ch); //输出   curl_close($ch); ?>


菜单click事件对于event和key,可使用$key=$postObj->data->key;读取



0 0