微博开放平台
微连接
移动应用
网站接入
电商服务商
电商商家
数据服务
数据服务
合作伙伴
微博支付
轻应用
粉丝服务
文档
推广
我的应用
登录
weibo
开发文档
首页
平台政策与指引
概述
平台公约
新手指南
开发者协议
应用运营管理规范
微连接分级管理办法
应用审核产品指南
应用安全开发注意事项
平台应用设计规范
微服务接入指南
微博登录接入
用微博帐号登录
授权机制
移动应用接入
移动应用介绍
移动应用SSO授权
微博Deep Link
媒体接入平台
头条文章开放接口
视频上传开放接口
电商接入平台
电商服务商接入
电商商家端接入
电商平台能力接口
粉丝服务平台
粉丝服务平台
新手接入指南
微信开发者迁移指南
接收消息
发送消息
自定义菜单
用户管理
生成带参数的二维码
Fans Service Platform
商业接口
商业数据接入指南
订阅服务手册(中文版)
订阅服务手册(英文版)
商业接口-REST API
商业数据常见问题
网站接入
网站接入介绍
微博API
微博API
接口访问频次权限
资源下载
SDK
微博标识下载
常见问题
联系我们
工具箱
链入页面
链出更改
特殊页面
查看源代码
跳转到:
导航
,
搜索
根据下列原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
{{api_desc2_en| uri=direct_messages| desc=Return the latest N direct message of authenticating user. Each message contain the sender and recipient’s profile.| format=XML/JSON| httpMethod=GET| needAuth=true| rateLimit=true| params={{api_args|since_id|false|int64|Returns then weibos with an ID greater than (that is, more recent than) the specified ID}} {{api_args|max_id|false|int64|Return the weibos with an ID smaller than the specified ID.录}} {{api_args|count|false|int, default is 20, max is 200.|Specify the number of weibos return in one page.。}} {{api_args|page|false|int, default is 1.|Specify results page. Based on the number of the authenticating user’s followings and the number of the followings’s weibos, the max number of weibos that page feature can access is different, usually up to about 1000 piceces.。}}| getParam=&count=5&page=2| postParam=| result= ===XML Example=== <pre> <?xml version="1.0" encoding="UTF-8"?> <direct-messages> <direct_message> <created_at>Fri Dec 03 14:30:01 +0800 2010</created_at> <id>710275891</id> <text>你参加的 "圈内招聘" 微群( http://sinaurl.cn/hbPhiL )被设置为 封闭 群组</text> <sender_id>1821898647</sender_id> <recipient_id>1658122963</recipient_id> <sender_screen_name>微群小助手</sender_screen_name> <recipient_screen_name>zhangwei217245</recipient_screen_name> <sender> <id>1821898647</id> <screen_name>微群小助手</screen_name> <name>微群小助手</name> <province>11</province> <city>8</city> <location>北京 海淀区</location> <description>新浪微群官方帐号!顶部导航【微群】可直接进入微群页面。您有任何意见或者建议,可随时@微群小助手 私信完全开放。合作或疑问请联系13810888467</description> <url>http://q.t.sina.com.cn/</url> <profile_image_url>http://tp4.sinaimg.cn/1821898647/50/1290508563/0</profile_image_url> <domain/> <gender>f</gender> <followers_count>6799</followers_count> <friends_count>12</friends_count> <statuses_count>53</statuses_count> <favourites_count>0</favourites_count> <created_at>Mon Sep 20 00:00:00 +0800 2010</created_at> <following>false</following> <verified>true</verified> <allow_all_act_msg>true</allow_all_act_msg> <geo_enabled>true</geo_enabled> </sender> <recipient> <id>1658122963</id> <screen_name>zhangwei217245</screen_name> <name>zhangwei217245</name> <province>11</province> <city>5</city> <location>北京 朝阳区</location> <description>ABCDE</description> <url/> <profile_image_url>http://tp4.sinaimg.cn/1658122963/50/1282754213</profile_image_url> <domain>zhangwei217245</domain> <gender>m</gender> <followers_count>24</followers_count> <friends_count>44</friends_count> <statuses_count>118</statuses_count> <favourites_count>3</favourites_count> <created_at>Tue Nov 03 00:00:00 +0800 2009</created_at> <following>false</following> <verified>false</verified> <allow_all_act_msg>false</allow_all_act_msg> <geo_enabled>true</geo_enabled> </recipient> </direct_message> ... </direct-messages> </pre> ===JSON示例=== <pre> [ { "sender_screen_name" : "微群小助手", "recipient_screen_name" : "zhangwei217245", "text" : "你参加的 \"圈内招聘\" 微群( http://sinaurl.cn/hbPhiL )被设置为 封闭 群组", "recipient" : { "name" : "zhangwei217245", "domain" : "zhangwei217245", "geo_enabled" : true, "followers_count" : 24, "statuses_count" : 118, "favourites_count" : 3, "city" : "5", "description" : "ABCDE", "verified" : false, "id" : 1658122963, "gender" : "m", "friends_count" : 44, "screen_name" : "zhangwei217245", "allow_all_act_msg" : false, "following" : false, "url" : "", "profile_image_url" : "http://tp4.sinaimg.cn/1658122963/50/1282754213", "created_at" : "Tue Nov 03 00:00:00 +0800 2009", "province" : "11", "location" : "北京 朝阳区" }, "sender" : { "name" : "微群小助手", "domain" : "", "geo_enabled" : true, "followers_count" : 6799, "statuses_count" : 53, "favourites_count" : 0, "city" : "8", "description" : "新浪微群官方帐号!顶部导航【微群】可直接进入微群页面。您有任何意见或者建议,可随时@微群小助手 私信完全开放。合作或疑问请联系13810888467", "verified" : true, "id" : 1821898647, "gender" : "f", "friends_count" : 12, "screen_name" : "微群小助手", "allow_all_act_msg" : true, "following" : false, "url" : "http://q.t.sina.com.cn/", "profile_image_url" : "http://tp4.sinaimg.cn/1821898647/50/1290508563/0", "created_at" : "Mon Sep 20 00:00:00 +0800 2010", "province" : "11", "location" : "北京 海淀区" }, "sender_id" : 1821898647, "recipient_id" : 1658122963, "id" : 710275891, "created_at" : "Fri Dec 03 14:30:01 +0800 2010" }, ... ] </pre> {{param_DM_en}} {{param_user_en}}| useAge=None| otherInfo= ====Java Example==== Please download Java SDK from . [[SDK/enen |Weibo SDK Development Kit Dowload Site]] <br> Sample Code: package weibo4j.examples; import weibo4j.DirectMessage; import weibo4j.Weibo; import weibo4j.WeiboException; import java.util.List; public class GetDirectMessages{ public static void main(String[] args) { if (args.length < 2) { System.out.println("No WeiboID/Password specified."); System.out.println("Usage: java weibo4j.examples.GetDirectMessages ID Password"); System.exit(-1); } Weibo weibo = new Weibo(args[0], args[1]); try { List<DirectMessage> messages = weibo.getDirectMessages(); for (DirectMessage message : messages) { System.out.println("Sender:" + message.getSenderScreenName()); System.out.println("Text:" + message.getText() + "\n"); } System.exit(0); } catch (WeiboException te) { System.out.println("Failed to get messages: " + te.getMessage()); System.exit(-1); } } } ===PHP Example=== Please download PHP SDK with OAUTH supported from [[SDK/en | Weibo SDK Development Kit Dowload Site]] <br> . Sample Code: <pre> //direct_messages $c = new WeiboClient( WB_AKEY , WB_SKEY , $_SESSION['last_key']['oauth_token'] , $_SESSION['last_key']['oauth_token_secret'] ); $msg = $c->list_dm(); if ($msg === false || $msg === null){ echo "Error occured"; return false; } if (isset($msg['error_code']) && isset($msg['error'])){ echo ('Error_code: '.$msg['error_code'].'; Error: '.$msg['error'] ); return false; } foreach($msg as $mail){ echo('Sender: '.$mail['sender_screen_name'].' Text: '.$mail['text'].' ; '); } </pre> }}
该页面使用的模板:
模板:Api args
(
查看源代码
)
模板:Api desc2 en
(
查看源代码
)
模板:Param DM en
(
查看源代码
)
模板:Param user en
(
查看源代码
)
返回到
Direct messages/en
。
反馈
分享
顶部