Receive General Message
(未显示1个用户的5个中间版本) | |||
第1行: | 第1行: | ||
− | After connecting with your callback url | + | After connecting with your callback url, Weibo Server will POST the general message to your URL when your account get new general messages. |
For each POST request from Weibo, developer can respond it by return specific JSON in response body. | 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. | 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. | ||
− | About eliminating the repetitive | + | About eliminating the repetitive messages which may result from the retry mechanism, we recommend you eliminating the repetitive message by using sender_id plus created_at. |
If developer can't respond in 5 seconds, developer can reply with blank string. Weibo Server will not do anything with your blank string and will not retry after receiving your blank string. | If developer can't respond in 5 seconds, developer can reply with blank string. Weibo Server will not do anything with your blank string and will not retry after receiving your blank string. | ||
第25行: | 第25行: | ||
{|width="100%" border="0" cellspacing="0" cellpadding="0" class="wiki_table" | {|width="100%" border="0" cellspacing="0" cellpadding="0" class="wiki_table" | ||
<html><colgroup><col class="tbF1"/><col class="tbF2" /><col /></colgroup></html> | <html><colgroup><col class="tbF1"/><col class="tbF2" /><col /></colgroup></html> | ||
− | !colspan="3" scope="col" |<span id="返回值说明"> | + | !colspan="3" scope="col" |<span id="返回值说明">the parameters</span> |
|- | |- | ||
− | |style="text-align:center; width: 12%"| | + | |style="text-align:center; width: 12%"|Parameters |
− | |style="text-align:center;width: 12%"| | + | |style="text-align:center;width: 12%"|Type |
− | |style="text-align:center;"| | + | |style="text-align:center;"|Decription |
|- | |- | ||
|type | |type | ||
第53行: | 第53行: | ||
|data | |data | ||
|string | |string | ||
− | | | + | |Text Type Message is blank |
|} | |} | ||
− | == | + | ==Position Type Message== |
+ | |||
+ | The JSON format of Position Type Message as the following: | ||
− | |||
<pre> | <pre> | ||
{ | { | ||
第75行: | 第76行: | ||
{|width="100%" border="0" cellspacing="0" cellpadding="0" class="wiki_table" | {|width="100%" border="0" cellspacing="0" cellpadding="0" class="wiki_table" | ||
<html><colgroup><col class="tbF1"/><col class="tbF2" /><col /></colgroup></html> | <html><colgroup><col class="tbF1"/><col class="tbF2" /><col /></colgroup></html> | ||
− | !colspan="3" scope="col" |<span id="返回值说明"> | + | !colspan="3" scope="col" |<span id="返回值说明">the parameters</span> |
|- | |- | ||
− | |style="text-align:center; width: 12%"| | + | |style="text-align:center; width: 12%"|Parameters |
− | |style="text-align:center;width: 12%"| | + | |style="text-align:center;width: 12%"|Type |
− | |style="text-align:center;"| | + | |style="text-align:center;"|Decription |
|- | |- | ||
|type | |type | ||
第87行: | 第88行: | ||
|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 | ||
− | | | + | |default content about 7 Chinese Characters“发送了一个位置” |
|- | |- | ||
|data | |data | ||
|string | |string | ||
− | | | + | |the content of this message |
|- | |- | ||
|data:longitude | |data:longitude | ||
|string | |string | ||
− | | | + | |longitude |
|- | |- | ||
|data:latitude | |data:latitude | ||
|string | |string | ||
− | | | + | |latitude |
|} | |} | ||
− | == | + | ==Voice Type Message== |
− | + | The JSON format of Voice Type Message as the following: | |
<pre> | <pre> | ||
{ | { | ||
第125行: | 第126行: | ||
"text": "发了一个语音消息", | "text": "发了一个语音消息", | ||
"data": { | "data": { | ||
− | "vfid": 821804459, // | + | "vfid": 821804459, // the sender can get the voice file by this ID |
− | "tovfid": 821804469 // | + | "tovfid": 821804469 // the receiver can get the voice file by this ID |
} | } | ||
} | } | ||
第133行: | 第134行: | ||
{|width="100%" border="0" cellspacing="0" cellpadding="0" class="wiki_table" | {|width="100%" border="0" cellspacing="0" cellpadding="0" class="wiki_table" | ||
<html><colgroup><col class="tbF1"/><col class="tbF2" /><col /></colgroup></html> | <html><colgroup><col class="tbF1"/><col class="tbF2" /><col /></colgroup></html> | ||
− | !colspan="3" scope="col" |<span id="返回值说明"> | + | !colspan="3" scope="col" |<span id="返回值说明">the parameters</span> |
|- | |- | ||
− | |style="text-align:center; width: 12%"| | + | |style="text-align:center; width: 12%"|Parameters |
− | |style="text-align:center;width: 12%"| | + | |style="text-align:center;width: 12%"|Type |
− | |style="text-align:center;"| | + | |style="text-align:center;"|Description |
|- | |- | ||
|type | |type | ||
第145行: | 第146行: | ||
|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 | ||
− | | | + | |default content about 9 Chinese Characters“发送了一个语音消息” |
|- | |- | ||
|data | |data | ||
|string | |string | ||
− | | | + | |the content of the voice type message |
|- | |- | ||
|data:vfid | |data:vfid | ||
|string | |string | ||
− | | | + | |vfid, the sender can get the voice file by this ID |
|- | |- | ||
|data:tovfid | |data:tovfid | ||
|string | |string | ||
− | | | + | |tovid, the receiver can get the voice file by this ID |
|} | |} | ||
<pre> | <pre> | ||
− | + | how to download the voice file? | |
− | curl "https://upload.api.weibo.com/2/mss/msget?access_token= | + | curl "https://upload.api.weibo.com/2/mss/msget?access_token=ACCESS_TOKEN&fid=TOVFID" |
− | 1." | + | 1."ACCESS_TOKEN":developer‘s access_token |
− | 2."TOVFID" | + | 2."TOVFID":the tovid in data parameter |
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
− | == | + | ==Image Type Message== |
− | + | The JSON format of Image Type Message as the following: | |
<pre> | <pre> | ||
{ | { | ||
第196行: | 第192行: | ||
"text": "发了一张图片", | "text": "发了一张图片", | ||
"data": { | "data": { | ||
− | "vfid": 821804459, // | + | "vfid": 821804459, // the sender can get the image file by this ID |
− | "tovfid": 821804469 // | + | "tovfid": 821804469 // the receiver can get the voice file by this ID |
} | } | ||
} | } | ||
第204行: | 第200行: | ||
{|width="100%" border="0" cellspacing="0" cellpadding="0" class="wiki_table" | {|width="100%" border="0" cellspacing="0" cellpadding="0" class="wiki_table" | ||
<html><colgroup><col class="tbF1"/><col class="tbF2" /><col /></colgroup></html> | <html><colgroup><col class="tbF1"/><col class="tbF2" /><col /></colgroup></html> | ||
− | !colspan="3" scope="col" |<span id="返回值说明"> | + | !colspan="3" scope="col" |<span id="返回值说明">the parameters</span> |
|- | |- | ||
− | |style="text-align:center; width: 12%"| | + | |style="text-align:center; width: 12%"|Parameters |
− | |style="text-align:center;width: 12%"| | + | |style="text-align:center;width: 12%"|Type |
− | |style="text-align:center;"| | + | |style="text-align:center;"|Description |
|- | |- | ||
|type | |type | ||
第216行: | 第212行: | ||
|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 | ||
− | | | + | |default content about 6 Chinese Characters“发了一张图片” |
|- | |- | ||
|data | |data | ||
|string | |string | ||
− | | | + | |the content of the voice type message |
|- | |- | ||
|data:vfid | |data:vfid | ||
|string | |string | ||
− | | | + | |vfid,the sender can get the voice file by this ID |
|- | |- | ||
|data:tovfid | |data:tovfid | ||
|string | |string | ||
− | | | + | |tovfid, the receiver can get the voice file by this ID |
|} | |} | ||
<pre> | <pre> | ||
− | + | how to download an image file? | |
− | curl "https://upload.api.weibo.com/2/mss/msget?access_token= | + | curl "https://upload.api.weibo.com/2/mss/msget?access_token=ACCESS_TOKEN&fid=TOVFID" |
+ | |||
+ | 1."ACCESS_TOKEN":developer‘s access_token | ||
+ | 2."TOVFID":the tovid in data parameter | ||
− | |||
− | |||
</pre> | </pre> |
2014年8月6日 (三) 15:11的最后版本
After connecting with your callback url, Weibo Server will POST the general message to your URL when your account get new general messages.
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.
About eliminating the repetitive messages which may result from the retry mechanism, we recommend you eliminating the repetitive message by using sender_id plus created_at.
If developer can't respond in 5 seconds, developer can reply with blank string. Weibo Server will not do anything with your blank string and will not retry after receiving your blank string.
目录 |
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": "the content of a general message", "data": {} }
the parameters | ||
---|---|---|
Parameters | Type | Decription |
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 | Text Type Message is blank |
Position Type Message
The JSON format of Position Type Message as the following:
{ "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" } }
the parameters | ||
---|---|---|
Parameters | Type | Decription |
type | string | position |
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 | default content about 7 Chinese Characters“发送了一个位置” |
data | string | the content of this message |
data:longitude | string | longitude |
data:latitude | string | latitude |
Voice Type Message
The JSON format of Voice Type Message as the following:
{ "type": "voice", "receiver_id": 1902538057, "sender_id": 2489518277, "created_at": "Mon Jul 16 18:09:20 +0800 2012", "text": "发了一个语音消息", "data": { "vfid": 821804459, // the sender can get the voice file by this ID "tovfid": 821804469 // the receiver can get the voice file by this ID } }
the parameters | ||
---|---|---|
Parameters | Type | Description |
type | string | voice |
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 | default content about 9 Chinese Characters“发送了一个语音消息” |
data | string | the content of the voice type message |
data:vfid | string | vfid, the sender can get the voice file by this ID |
data:tovfid | string | tovid, the receiver can get the voice file by this ID |
how to download the voice file? curl "https://upload.api.weibo.com/2/mss/msget?access_token=ACCESS_TOKEN&fid=TOVFID" 1."ACCESS_TOKEN":developer‘s access_token 2."TOVFID":the tovid in data parameter
Image Type Message
The JSON format of Image Type Message as the following:
{ "type": "image", "receiver_id": 1902538057, "sender_id": 2489518277, "created_at": "Mon Jul 16 18:09:20 +0800 2012", "text": "发了一张图片", "data": { "vfid": 821804459, // the sender can get the image file by this ID "tovfid": 821804469 // the receiver can get the voice file by this ID } }
the parameters | ||
---|---|---|
Parameters | Type | Description |
type | string | image |
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 | default content about 6 Chinese Characters“发了一张图片” |
data | string | the content of the voice type message |
data:vfid | string | vfid,the sender can get the voice file by this ID |
data:tovfid | string | tovfid, the receiver can get the voice file by this ID |
how to download an image file? curl "https://upload.api.weibo.com/2/mss/msget?access_token=ACCESS_TOKEN&fid=TOVFID" 1."ACCESS_TOKEN":developer‘s access_token 2."TOVFID":the tovid in data parameter