Receive General Message

跳转到: 导航, 搜索
(以“建立首次连接后,当认证用户有新消息时,微博消息推送服务会POST消息数据包到开发者填写的URL上; (<font style="color:red">注...”为内容创建页面)
 
第1行: 第1行:
 +
After
 +
 
建立首次连接后,当认证用户有新消息时,微博消息推送服务会POST消息数据包到开发者填写的URL上;
 
建立首次连接后,当认证用户有新消息时,微博消息推送服务会POST消息数据包到开发者填写的URL上;
  
(<font style="color:red">注意:</font>需要对接收到的消息体type或subtype做兼容,当出现未知类型时可忽略此消息。)
+
 
 +
For each POST request from Weibo, developer can respond it by return specific JSON in response body.
 +
Weibo Server will disconnect and request your callback url again if can't receive any response in 5 seconds. Weibo Server will retry 3 times in total.
  
 
对于每一个POST请求,开发者在响应包(Get)中返回特定JSON包,对该消息进行响应。微博服务器在五秒内收不到响应会断掉连接,并且重新发起请求,总共重试三次;  
 
对于每一个POST请求,开发者在响应包(Get)中返回特定JSON包,对该消息进行响应。微博服务器在五秒内收不到响应会断掉连接,并且重新发起请求,总共重试三次;  
  
 
关于重试的消息排重,目前微博消息暂时不支持消息ID,推荐使用FromUserName + CreateTime 排重;
 
关于重试的消息排重,目前微博消息暂时不支持消息ID,推荐使用FromUserName + CreateTime 排重;
 +
 +
If developer can't respond in 5 seconds, developer can reply with.
 +
Weibo Server will not deal with
 +
  
 
假如开发者无法保证在五秒内处理并回复,可以直接回复空串,微博服务器不会对此作任何处理,并且不会发起重试。
 
假如开发者无法保证在五秒内处理并回复,可以直接回复空串,微博服务器不会对此作任何处理,并且不会发起重试。
  
  
==纯文本类型私信消息==
 
  
纯文本类型私信消息JSON格式如下:
+
==Text Type Message==
 +
 
 +
The JSON format of Text Type Message as the following:
 
<pre>
 
<pre>
 
{
 
{
第38行: 第47行:
 
|receiver_id
 
|receiver_id
 
|int64
 
|int64
|消息的接收者
+
|the receiver of this message
 
|-
 
|-
 
|sender_id
 
|sender_id
 
|int64
 
|int64
|消息的发送者
+
|the sender of this message
 
|-
 
|-
 
|created_at
 
|created_at
 
|string
 
|string
|消息创建时间
+
|the creation time of this message
 
|-
 
|-
 
|text
 
|text
 
|string
 
|string
|私信内容
+
|the content of this message
 
|-
 
|-
 
|data
 
|data

2014年8月6日 (三) 10:56的版本

After

建立首次连接后,当认证用户有新消息时,微博消息推送服务会POST消息数据包到开发者填写的URL上;


For each POST request from Weibo, developer can respond it by return specific JSON in response body. Weibo Server will disconnect and request your callback url again if can't receive any response in 5 seconds. Weibo Server will retry 3 times in total.

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

关于重试的消息排重,目前微博消息暂时不支持消息ID,推荐使用FromUserName + CreateTime 排重;

If developer can't respond in 5 seconds, developer can reply with. Weibo Server will not deal with


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


目录

Text Type Message

The JSON format of Text Type Message as the following:

{
    "type": "text",
    "receiver_id": 1902538057,
    "sender_id": 2489518277,
    "created_at": "Mon Jul 16 18:09:20 +0800 2012",
    "text": "私信或留言内容",
    "data": {}
}
返回值说明
属性 值的类型 说明描述
type string text
receiver_id int64 the receiver of this message
sender_id int64 the sender of this message
created_at string the creation time of this message
text string the content of this message
data string 消息内容,纯文本私信或留言为空

位置类型私信消息

位置类型私信消息JSON格式如下:

{
    "type": "position",
    "receiver_id": 1902538057,
    "sender_id": 2489518277,
    "created_at": "Mon Jul 16 18:09:20 +0800 2012",
    "text": "我在这里: http://t.cn/zQgLLYO",
    "data": {
        "longitude": "116.308586",
        "latitude": "39.982525"
      }
}
返回值说明
属性 值的类型 说明描述
type string position
receiver_id int64 消息的接收者
sender_id int64 消息的发送者
created_at string 消息创建时间
text string 原位置私信文本,没有时用默认文案“发送了一个位置”
data string 消息内容
data:longitude string 经度
data:latitude string 纬度

语音类型私信消息

语音类型私信消息JSON格式如下:

{
    "type": "voice",
    "receiver_id": 1902538057,
    "sender_id": 2489518277,
    "created_at": "Mon Jul 16 18:09:20 +0800 2012",
    "text": "发了一个语音消息",
    "data": {
        "vfid": 821804459,    // 发送者用此ID查看语音
        "tovfid": 821804469  // 接收者用此ID查看语音
    }
}
返回值说明
属性 值的类型 说明描述
type string voice
receiver_id int64 消息的接收者
sender_id int64 消息的发送者
created_at string 消息创建时间
text string 私信内容
data string 消息内容,纯文本私信或留言为空
data:vfid string 语音文件ID,发送者通过此ID读取语音
data:tovfid string 语音文件ID,接收者通过此ID读取语音
查看(下载)认证用户接收到的语音方法一
curl "https://upload.api.weibo.com/2/mss/msget?access_token=RECIPIENT_ACCESS_TOKEN&fid=TOVFID"

1."RECIPIENT_ACCESS_TOKEN":返回结果中接收者(recipient_id)通过OAuth2授权返回的access_token;
2."TOVFID":返回结果data字段中的tovfid。

查看(下载)认证用户接收到的语音方法二
curl -u "USERNAME:PASSWORD" "https://upload.api.weibo.com/2/mss/msget?source=APPKEY&fid=TOVFID"

1."USERNAME:PASSWORD"为"recipient_id"(认证用户)的微博登录用户名和密码,此时方法二中的APPKEY应用所有者为"recipient_id";
2."TOVFID":返回结果data字段中的tovfid。

图片类型私信消息

图片类型私信消息JSON格式如下:

{
    "type": "image",
    "receiver_id": 1902538057,
    "sender_id": 2489518277,
    "created_at": "Mon Jul 16 18:09:20 +0800 2012",
    "text": "发了一张图片",
    "data": {
        "vfid": 821804459,     // 发送者用此ID查看图片
        "tovfid": 821804469    // 接收者用此ID查看图片
    }
}
返回值说明
属性 值的类型 说明描述
type string image
receiver_id int64 消息的接收者
sender_id int64 消息的发送者
created_at string 消息创建时间
text string 私信内容
data string 消息内容,纯文本私信或留言为空
data:vfid string 图片ID,发送者通过此ID读取图片
data:tovfid string 图片ID,接收者通过此ID读取图片
查看(下载)图片
curl "https://upload.api.weibo.com/2/mss/msget?access_token=RECIPIENT_ACCESS_TOKEN&fid=TOVFID"

1,"RECIPIENT_ACCESS_TOKEN":返回结果中接收者(receiver_id)通过OAuth2授权返回的access_token;
2,"TOVFID":返回结果data字段中的tovfid。