自定义菜单查询接口

跳转到: 导航, 搜索
(以“=自定义菜单查询接口= 自定义菜单查询接口 ==URL== https://api.weibo.com/2/messages/menu/show.json ==HTTP请求方式== POST ==是否需要登...”为内容创建页面)
 
(是否需要登录)
 
(未显示2个用户的10个中间版本)
第4行: 第4行:
  
 
==URL==
 
==URL==
https://api.weibo.com/2/messages/menu/show.json
+
https://m.api.weibo.com/2/messages/menu/show.json
 
+
 
+
  
 
==HTTP请求方式==
 
==HTTP请求方式==
POST
+
GET
 
+
==是否需要登录==
+
是<br/>
+
关于登录授权,参见 [[授权机制说明|如何登录授权]]
+
  
 +
请求说明,https://m.api.weibo.com/2/messages/menu/show.json?access_token=ACCESS_TOKEN
  
 
==接口请求参数==
 
==接口请求参数==
第23行: 第18行:
 
!width="10%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"|类型及范围
 
!width="10%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"|类型及范围
 
!width="75%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"|说明
 
!width="75%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"|说明
{{api_args|source|false|string|采用OAuth授权方式不需要此参数,其他授权方式为必填参数,数值为应用的AppKey。}}
+
{{api_args|access_token|true|string|在账号Profile页--> 管理中心 --> 粉丝服务--> 高级功能--> 开发模式中获取,详细参考 [[Messages_api/access_token|获取粉丝服务平台开发接口的access token]]。}}
{{api_args|access_token|false|string|采用OAuth授权方式为必填参数,其他授权方式不需要此参数,OAuth授权后获得。}}
+
{{api_args|type|true|string|需要以何种类型的消息进行响应,text:纯文本、articles:图文、position:位置。}}
+
{{api_args|data|true|string|消息数据,具体内容严格遵循type类型对应格式,必须为json做URLEncode后的字符串格式,采用UTF-8编码。}}
+
{{api_args|receiver_id|false|int64|消息接收方的ID。}}
+
{{api_args|id|false|int64|需要响应的消息ID,该字段仅仅针对使用message/receive长连接服务接收到的消息;如果使用消息推送服务,则必须使用receiver_id参数而不是id参数}}
+
 
|}
 
|}
 
==注意事项==
 
*1、接口调用支持两种方式,一是采用OAuth方式调用,二是使用appkey所有者帐号通过Base Auth的方式调用;
 
*2、如果调用走OAuth方式,则access_token参数必填,id参数和receiver_id参数必填一个;
 
*3、如果调用走Base Auth方式,则调用接口的登录帐号必须为当前应用的所有者,并且source参数必填,id参数必填;
 
*4、使用message/receive长连接服务接收上行信息的开发者才能获取到消息id参数,使用消息推送服务的开发者无法获取消息id参数,因此需要通过receiver_id来指定消息接收方,而消息发送方的uid微博会从access_token中获取;
 
*5、调用接口时,需要消息发送方有针对于消息接收方的消息配额;一般来说,如果消息接收方给消息发送方主动发送过消息,则在7天内,消息发送方具备针对于消息接收方的主动配额一条;
 
*6、调用时如果指定了id参数,则需要
 
** 指定ID的新消息对应的原接收者已指定当前应用为其开发,且该接收者已开启“开发模式”,详见:[[粉丝服务开发模式指南|粉丝服务开发模式指南]];
 
** 指定ID的新消息对应的原接收者身份发出此消息;
 
** 指定ID的新消息对应的原发送者将收到此消息;
 
** 发送者未被屏蔽或拉黑时消息进私信箱;
 
 
此接口不得用于推广或引导用户使用任何与新浪微博有直接竞争关系的公司的服务,否则将永久关停指定应用或V用户使用资格。
 
 
==PHP示例代码==
 
 
PHP示例代码下载:[[Messages/dev_demo|下载]]
 
 
 
==蓝V可回复的私信类型==
 
 
当前支持蓝V回复的私信类型(type)中,data参数支持的参数:
 
 
 
<h3>1、纯文本类型私信消息:text</h3>
 
<pre>
 
{
 
    "text": "纯文本回复"
 
}
 
</pre>
 
<div class="wiki_kit">
 
 
 
{|width="100%" border="0" cellspacing="0" cellpadding="0" class="wiki_table"
 
<html><colgroup><col class="tbF1"/><col class="tbF2" /><col /></colgroup></html>
 
!colspan="4" scope="col" |<span id="data参数支持的参数">data参数支持的参数</span>
 
|-
 
|style="text-align:center; width: 12%"|参数名称
 
|style="text-align:center;width: 12%"|值的类型
 
|style="text-align:center;width: 11%"|是否必填
 
|style="text-align:center;"|说明描述
 
|-
 
|text
 
|string
 
|true
 
|要回复的私信文本内容。文本大小必须小于300个汉字。
 
|}
 
举例:
 
当data对应json为{"text": "纯文本响应"} 时,则进行URLEncode后对应data参数值为:"%7b%0a++++%22text%22%3a+%22%e7%ba%af%e6%96%87%e6%9c%ac%e5%93%8d%e5%ba%94%22%0a%7d"。
 
 
则对应的调用为:
 
<pre>
 
curl -u "USERNAME:PASSWORD" -d "source=YOUR_APPKEY&id=1307180000*****&type=text&data=%7b%0a++++%22text%22%3a+%22%e7%ba%af%e6%96%87%e6%9c%ac%e5%93%8d%e5%ba%94%22%0a%7d" "https://m.api.weibo.com/2/messages/reply.json" -k
 
</pre>
 
 
 
<h3>2、图文类型私信消息:articles</h3>
 
<pre>
 
{
 
    "articles": [
 
        {
 
            "display_name": "两个故事",
 
            "summary": "今天讲两个故事,分享给你。谁是公司?谁又是中国人?​",
 
            "image": "http://storage.mcp.weibo.cn/0JlIv.jpg",
 
            "url": "http://e.weibo.com/mediaprofile/article/detail?uid=1722052204&aid=983319"
 
        },
 
        ... //最多支持8个图文,建议为1或3个
 
    ]
 
}
 
</pre>
 
 
 
<div class="wiki_kit">
 
{|width="100%" border="0" cellspacing="0" cellpadding="0" class="wiki_table"
 
<html><colgroup><col class="tbF1"/><col class="tbF2" /><col /></colgroup></html>
 
!colspan="4" scope="col" |<span id="data参数支持的参数">data参数支持的参数</span>
 
|-
 
|style="text-align:center; width: 12%"|参数名称
 
|style="text-align:center;width: 12%"|值的类型
 
|style="text-align:center;width: 11%"|是否必填
 
|style="text-align:center;"|说明描述
 
|-
 
|articles:display_name
 
|string
 
|true
 
|图文的显示名称标题
 
|-
 
|articles:summary
 
|string
 
|true
 
|图文的文字描述,大于等于2个图文时,仅显示第一个图文的描述
 
|-
 
|articles:image
 
|string
 
|true
 
|图文的缩略显示图片,需为JPG、PNG格式,单图及多图第一张推荐使用280*155,多图非第一张推荐使用64*64
 
|-
 
|articles:url
 
|string
 
|true
 
|图文的URL地址,点击后跳转
 
|}
 
 
 
<h3>3、位置类型私信消息:position </h3>
 
<pre>
 
{
 
    "longitude": "116.308586",
 
    "latitude": "39.982525"
 
}
 
</pre>
 
 
 
<div class="wiki_kit">
 
{|width="100%" border="0" cellspacing="0" cellpadding="0" class="wiki_table"
 
<html><colgroup><col class="tbF1"/><col class="tbF2" /><col /></colgroup></html>
 
!colspan="4" scope="col" |<span id="data参数支持的参数">data参数支持的参数</span>
 
|-
 
|style="text-align:center; width: 12%"|参数名称
 
|style="text-align:center;width: 12%"|值的类型
 
|style="text-align:center;width: 11%"|是否必填
 
|style="text-align:center;"|说明描述
 
|-
 
|longitude
 
|string
 
|true
 
|经度
 
|-
 
|latitude
 
|string
 
|true
 
|纬度
 
|}
 
 
  
 
==返回结果==
 
==返回结果==
第170行: 第25行:
 
// 成功返回
 
// 成功返回
 
{
 
{
     "id": 1211260020031347,
+
     "menu": {
    "type": "TYPE",
+
        "button": [
    "receiver_id": 1902538057,
+
            {
    "sender_id": 2489518277,
+
                "type": "click",
    "created_at": "Mon Jul 16 18:09:20 +0800 2012",
+
                "name": "获取优惠券",
    "text": "您的余额还剩2元。",
+
                "key": "get_groupon"
    "data": {}
+
            },
 +
            {
 +
                "type": "click",
 +
                "name": "查询客服电话",
 +
                "key": "the_big_brother_need_your_phone"
 +
            },
 +
            {
 +
                "name": "菜单",
 +
                "sub_button": [
 +
                    {
 +
                        "type": "view",
 +
                        "name": "网上4S店",
 +
                        "url": "http://apps.weibo.com/1838358847/8rYu1uHD"
 +
                    },
 +
                    {
 +
                        "type": "view",
 +
                        "name": "砍价团",
 +
                        "url": "http://apps.weibo.com/1838358847/8s1i6v74"
 +
                    },
 +
                    {
 +
                        "type": "click",
 +
                        "name": "么么哒",
 +
                        "key": "memeda"
 +
                    }
 +
                ]
 +
            }
 +
        ]
 +
    }
 
}
 
}
  
 
// 失败返回
 
// 失败返回
 
{
 
{
     "request": "/2/messages/reply.json",
+
     "request": "/2/messages/menu/show.json",
 
     "error_code": 264XX,
 
     "error_code": 264XX,
 
     "error": "error message."
 
     "error": "error message."

2014年6月11日 (三) 22:46的最后版本

自定义菜单查询接口

自定义菜单查询接口

URL

https://m.api.weibo.com/2/messages/menu/show.json

HTTP请求方式

GET

请求说明,https://m.api.weibo.com/2/messages/menu/show.json?access_token=ACCESS_TOKEN

接口请求参数

  必选 类型及范围 说明
access_token true string 在账号Profile页--> 管理中心 --> 粉丝服务--> 高级功能--> 开发模式中获取,详细参考 获取粉丝服务平台开发接口的access token

返回结果

// 成功返回
{
    "menu": {
        "button": [
            {
                "type": "click",
                "name": "获取优惠券",
                "key": "get_groupon"
            },
            {
                "type": "click",
                "name": "查询客服电话",
                "key": "the_big_brother_need_your_phone"
            },
            {
                "name": "菜单",
                "sub_button": [
                    {
                        "type": "view",
                        "name": "网上4S店",
                        "url": "http://apps.weibo.com/1838358847/8rYu1uHD"
                    },
                    {
                        "type": "view",
                        "name": "砍价团",
                        "url": "http://apps.weibo.com/1838358847/8s1i6v74"
                    },
                    {
                        "type": "click",
                        "name": "么么哒",
                        "key": "memeda"
                    }
                ]
            }
        ]
    }
}

// 失败返回
{
    "request": "/2/messages/menu/show.json",
    "error_code": 264XX,
    "error": "error message."
}



文档更新时间: 2014-06-11