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

菜单创建的方法为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();//新建curl
curl_setopt($ch, CURLOPT_URL, $url);//url  
curl_setopt($ch, CURLOPT_POST, 1);  //post
curl_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);  //post
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);//post内容  
curl_exec($ch); //输出   
curl_close($ch); 

?>


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



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值