发送被动响应消息

跳转到: 导航, 搜索
(回复纯文本消息)
(回复图文消息)
 
(未显示1个用户的8个中间版本)
第15行: 第15行:
 
{
 
{
 
     "result": true,
 
     "result": true,
     "receiver_id":123,
+
     "receiver_id":456,
     "sender_id":456,
+
     "sender_id":123,
     "tpye": "text",
+
     "type": "text",
 
     "data":"{
 
     "data":"{
 
         "text": "中文消息"
 
         "text": "中文消息"
第25行: 第25行:
 
//返回样例
 
//返回样例
 
{
 
{
"result":true,
+
    "result":true,
"sender_id":"123",
+
    "sender_id":"123",
"receiver_id":"456",
+
    "receiver_id":"456",
"type":"text",
+
    "type":"text",
"data":"%7B%22text%22%3A%22%E4%B8%AD%E6%96%87%E6%B6%88%E6%81%AF%22%7D"
+
    "data":"%7B%22text%22%3A%22%E4%B8%AD%E6%96%87%E6%B6%88%E6%81%AF%22%7D"
 
}
 
}
 
</pre>
 
</pre>
第58行: 第58行:
 
{
 
{
 
     "result": true,
 
     "result": true,
     "receiver_id":123456,
+
     "receiver_id":456,
     "sender_id":123123,
+
     "sender_id":123,
 
     "type": "articles",
 
     "type": "articles",
 
     "data": {
 
     "data": {
第72行: 第72行:
 
     ]
 
     ]
 
  }
 
  }
 +
}
 +
 +
//返回样例
 +
{
 +
    "result": true,
 +
    "sender_id":"123",
 +
    "receiver_id":"456",
 +
    "type": "articles",
 +
    "data":"%7B%22articles%22%3A%5B%7B%22display_name%22%3A%22%E4%B8%A4%E4%B8%AA%E6%95%85%E4%BA%
 +
8B%22%2C%22summary%22%3A%22%E4%BB%8A%E5%A4%A9%E8%AE%B2%E4%B8%A4%E4%B8%AA%E6%95%85%E4%BA%8B%EF%BC%8C%E5%88%86%E4%BA%AB%E7%BB%99%E4%BD%A0%E3%80%82%E8%B0%81%E6%98%AF%E5%85%AC%E5%8F%B8%EF%BC%9F%E8%B0%81%E5%8F%88%E6%98%AF%E4%B8%AD%E5%9B%BD%E4%BA%BA%EF%BC%9F%E2%80%8B%22%2C%22image%22%3A%22http%3A%2F%2Fstorage.mcp.weibo.cn%2F0JlIv.jpg%22%2C%22url%22%3A%22http%3A%2F%2Fe.weibo.com%2Fmediaprofile%2Farticle%2Fdetail%3Fuid%3D1722052204%26aid%3D983319%22%7D%5D%7D"
 
}
 
}
 
</pre>
 
</pre>
第103行: 第113行:
 
|string
 
|string
 
|true
 
|true
|图文的URL地址,点击后跳转
+
|图文的URL地址,点击后跳转(注:该url必须为完整的url,例如, http://weibo.com/xxx ,如果省略掉”http:// “,则无法发送图文消息)
 
|}
 
|}
 
  
 
==位置类型私信消息==
 
==位置类型私信消息==
第112行: 第121行:
 
{
 
{
 
     "result": true,
 
     "result": true,
     "receiver_id":123456,
+
     "receiver_id":456,
     "sender_id":123123,
+
     "sender_id":123,
 
     "type": "position",
 
     "type": "position",
 
     "data": {
 
     "data": {
     "longitude": "116.308586",
+
     "longitude": "344.3344",
     "latitude": "39.982525"
+
     "latitude": "232.343434"
 
                   }
 
                   }
 +
}
 +
 +
//返回样例
 +
{
 +
    "result":true,
 +
    "sender_id":"123",
 +
    "receiver_id":"456",
 +
    "type":"position",
 +
    "data":"%7B%22longitude%22%3A%22344.3344%22%2C%22latitude%22%3A%22232.343434%22%7D"
 
}
 
}
  

2014年8月20日 (三) 11:52的最后版本

对于每一个POST请求,开发者在响应包(Get)中返回特定JSON结构或者XML结构,对该消息进行响应(现支持回复文本、图文消息)。

微博服务器在五秒内收不到响应会断掉连接,并且重新发起请求,总共重试三次;

关于重试的消息排重,推荐使用FromUserName + CreateTime 排重;

假如开发者无法保证在五秒内处理并回复,可以直接回复空串,微博服务器不会对此作任何处理,并且不会发起重试。这种情况下,可以使用客服消息接口进行异步回复。


回复纯文本消息

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

{
    "result": true,
    "receiver_id":456,
    "sender_id":123,
    "type": "text",
    "data":"{
         "text": "中文消息"
                 }"
}

//返回样例
{
    "result":true,
    "sender_id":"123",
    "receiver_id":"456",
    "type":"text",
    "data":"%7B%22text%22%3A%22%E4%B8%AD%E6%96%87%E6%B6%88%E6%81%AF%22%7D"
}


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":456,
    "sender_id":123,
    "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个
    ]
 }
}

//返回样例
{
    "result": true,
    "sender_id":"123",
    "receiver_id":"456",
    "type": "articles",
    "data":"%7B%22articles%22%3A%5B%7B%22display_name%22%3A%22%E4%B8%A4%E4%B8%AA%E6%95%85%E4%BA%
8B%22%2C%22summary%22%3A%22%E4%BB%8A%E5%A4%A9%E8%AE%B2%E4%B8%A4%E4%B8%AA%E6%95%85%E4%BA%8B%EF%BC%8C%E5%88%86%E4%BA%AB%E7%BB%99%E4%BD%A0%E3%80%82%E8%B0%81%E6%98%AF%E5%85%AC%E5%8F%B8%EF%BC%9F%E8%B0%81%E5%8F%88%E6%98%AF%E4%B8%AD%E5%9B%BD%E4%BA%BA%EF%BC%9F%E2%80%8B%22%2C%22image%22%3A%22http%3A%2F%2Fstorage.mcp.weibo.cn%2F0JlIv.jpg%22%2C%22url%22%3A%22http%3A%2F%2Fe.weibo.com%2Fmediaprofile%2Farticle%2Fdetail%3Fuid%3D1722052204%26aid%3D983319%22%7D%5D%7D"
}
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地址,点击后跳转(注:该url必须为完整的url,例如, http://weibo.com/xxx ,如果省略掉”http:// “,则无法发送图文消息)

位置类型私信消息

{
    "result": true,
    "receiver_id":456,
    "sender_id":123,
    "type": "position",
    "data": {
    "longitude": "344.3344",
    "latitude": "232.343434"
                  }
}

//返回样例
{
    "result":true,
    "sender_id":"123",
    "receiver_id":"456",
    "type":"position",
    "data":"%7B%22longitude%22%3A%22344.3344%22%2C%22latitude%22%3A%22232.343434%22%7D"
}


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

php代码示例

java代码示例

文档更新时间: 2014-08-20