2/direct messages/send
direct_messages/send
发送一条私信。
URL
https://c.api.weibo.com/2/direct_messages/send.json
支持格式
JSON
HTTP请求方式
POST
是否需要登录
是
关于登录授权,参见 如何登录授权
访问授权限制
请求所有商业接口:
- 50000次/小时/IP;
- 50000次/小时/IP;
请求参数
必选 | 类型及范围 | 说明 | |
---|---|---|---|
source | false | string | 采用OAuth授权方式不需要此参数,其他授权方式为必填参数,数值为应用的AppKey。 |
access_token | false | string | 采用OAuth授权方式为必填参数,其他授权方式不需要此参数,OAuth授权后获得。 |
text | true | string | 要发送的消息内容。需要做URLEncode,文本大小必须小于300个汉字。 |
uid | false | string | 私信接收方的用户ID。 |
screen_name | false | string | 私信接收方的微博昵称。在用户ID与微博昵称容易混淆的时候,使用该参数。 |
注意事项
- uid、screen_name两个参数必选其一,uid优先;
- uid必须是当前用户的粉丝,否则不能发送;
- 接口需要验证当前用户是否在uid的黑名单中,如果是,则不能发送;
- 接口需要验证uid的私信接收设置,如果设置为不能接收当前用户发送到私信,则不能发送;
返回结果
JSON示例
{ "id":3332910801173380, "idstr":"3332910801173380", "created_at":"Fri Jul 08 15:48:42 +0800 2011", "text":"私信1", "sender_id":4294917290, "recipient_id":2125034703, "sender_screen_name":"sso20333333333", "recipient_screen_name":"zhaoya0029", "mid":"3332910801173380", "geo":null, "sender": { "id": 1763071480, "idstr": "1763071480", "screen_name": "十分红处", "name": "十分红处", "province": "11", "city": "8", "location": "", "description": "要喜欢巧克力哦~~~", "url": "", "profile_image_url": "http://tp1.sinaimg.cn/1763071480/50/5626596159/0", "profile_url": "qlwan", "domain": "qlwan", "weihao": "", "gender": "f", "followers_count": 63, "friends_count": 105, "statuses_count": 201, "favourites_count": 5, "created_at": "Thu Jun 17 00:00:00 +0800 2010", "following": false, "allow_all_act_msg": false, "geo_enabled": true, "verified": false, "verified_type": -1, "allow_all_comment": false, "avatar_large": "http://tp1.sinaimg.cn/1763071480/180/5626596159/0", "verified_reason": "", "follow_me": false, "online_status": 0, "bi_followers_count": 27, "lang": "zh-cn" }, "recipient": { "id": 1716448455, "idstr": "1716448455", "screen_name": "牛奶_蜜豆", "name": "牛奶_蜜豆", "province": "42", "city": "1", "location": "", "description": "", "url": "", "profile_image_url": "http://tp4.sinaimg.cn/1716448455/50/5625663956/0", "profile_url": "niunaimidou", "domain": "niunaimidou", "weihao": "842627130", "gender": "f", "followers_count": 227, "friends_count": 363, "statuses_count": 680, "favourites_count": 10, "created_at": "Mon Mar 22 00:00:00 +0800 2010", "following": false, "allow_all_act_msg": false, "geo_enabled": true, "verified": false, "verified_type": -1, "allow_all_comment": true, "avatar_large": "http://tp4.sinaimg.cn/1716448455/180/5625663956/0", "verified_reason": "1 90 q", "follow_me": false, "online_status": 0, "bi_followers_count": 143, "lang": "zh-cn" }, "att_ids":[ 234524634563, 235326347634 ], "status_id":3634764574 }
关于错误返回值与错误代码,参见 错误代码说明
字段说明
无
其他
无