发送被动响应消息

跳转到: 导航, 搜索
第94行: 第94行:
 
|}
 
|}
  
 +
 +
==位置类型私信消息==
 +
 +
<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
 +
|纬度
 +
|}
  
 
==位置类型私信消息==
 
==位置类型私信消息==

2014年4月20日 (日) 16:32的版本

对于每一个POST请求,开发者在响应包(Get)中返回特定JSON包,对该消息进行响应。微博服务器在五秒内收不到响应会断掉连接,并且重新发起请求,总共重试三次; 关于重试的消息排重,推荐使用消息ID排重。

假如开发者无法保证在五秒内处理并回复,可以直接回复空串,微博服务器不会对此作任何处理,并且不会发起重试。


目录

回复纯文本消息

如果回复纯文本消息,则返回JSON格式如下: 注意:JSON格式中的data字段内容必须进行UTF8格式的URLEncode

{
    "result": true,
    "receiver_id":123456,
    "sender_id":123123,
    "tpye": "text",
    "data":"{
         "text": "你好"
                 }"
}


data参数支持的参数
参数名称 值的类型 是否必填 说明描述
text string true 要回复的私信文本内容。文本大小必须小于300个汉字。

举例: 当data对应json为{"text": "纯文本响应"} 时,则进行URLEncode后对应data参数值为:"%7B%22text%22%3A%20%22%E7%BA%AF%E6%96%87%E6%9C%AC%E5%93%8D%E5%BA%94%22%7D%20"。


回复图文消息

如果回复图文消息,则返回JSON格式如下:

{
    "result": true,
    "receiver_id":123456,
    "sender_id":123123,
    "type": "articles",
    "data": {
    "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个
    ]
 }
}
data参数支持的参数
参数名称 值的类型 是否必填 说明描述
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地址,点击后跳转


位置类型私信消息

{
    "longitude": "116.308586",
    "latitude": "39.982525"
}


data参数支持的参数
参数名称 值的类型 是否必填 说明描述
longitude string true 经度
latitude string true 纬度

位置类型私信消息

{
    "longitude": "116.308586",
    "latitude": "39.982525"
}


data参数支持的参数
参数名称 值的类型 是否必填 说明描述
longitude string true 经度
latitude string true 纬度