Direct messages/new

跳转到: 导航, 搜索
(direct_messages/new)
第1行: 第1行:
== direct_messages/new ==
+
== 发送私信 ==
登陆用户发送一条私信。必须包含参数user和text,请求必须使用POST方式提交。成功将返回完整的发送消息。
+
发送一条私信。必须包含参数user和text,请求必须使用POST方式提交。成功将返回完整的发送消息。
  
Sends a new direct message to the specified user from the authenticating user. Requires both the user and text parameters. Request must be a POST. Returns the sent message in the requested format when successful.
+
=== URL===
 
+
=== URL: ===
+
 
http://api.t.sina.com.cn/direct_messages/new.format
 
http://api.t.sina.com.cn/direct_messages/new.format
 
   
 
   
===Formats:===
+
===格式===
 
xml, json
 
xml, json
 
   
 
   
=== HTTP Method(s): ===
+
=== HTTP请求方式===
 
POST
 
POST
 
   
 
   
===Requires Authentication (about authentication):===
+
===是否需要身份验证===
 
true
 
true
 
   
 
   
===API rate limited (about rate limiting):===
+
===请求数限制===
 
false
 
false
 
   
 
   
===Parameters:===
+
===请求参数===
 
* user:  必须参数.  UID或账户名. 为了支持数字的账户名,需选填写下面2个参数screen_name或user_id:  
 
* user:  必须参数.  UID或账户名. 为了支持数字的账户名,需选填写下面2个参数screen_name或user_id:  
 
* screen_name: 账户名
 
* screen_name: 账户名
第25行: 第23行:
 
* text:  必须参数.  要发生的消息内容,需要做URLEncode,文本大小必须小于140个汉字.  
 
* text:  必须参数.  要发生的消息内容,需要做URLEncode,文本大小必须小于140个汉字.  
  
 
+
===使用说明===
* user:  Required.  The ID or screen name of the recipient user. In order to support numeric screen names we will accept either of the following two parameters in place of the user parameter:
+
* screen_name: screen name of the recipient user
+
* user_id: user id of the recipient user
+
* text:  Required.  The text of your direct message.  Be sure to URL encode as necessary, and keep it under 140 characters.
+
 
+
===Usage notes:===
+
 
* 此接口问更新受限接口,越权将返回http 403 错误
 
* 此接口问更新受限接口,越权将返回http 403 错误
 
* This method is subject to update limits. A HTTP 403 will be returned if this limit has been hit.  
 
* This method is subject to update limits. A HTTP 403 will be returned if this limit has been hit.  
  
===Response (about return values): ===
+
===Response ===
XML example (truncated):
+
XML示例:
 
  <?xml version="1.0" encoding="UTF-8"?>
 
  <?xml version="1.0" encoding="UTF-8"?>
 
  <direct_message>
 
  <direct_message>
第51行: 第43行:
 
  <screen_name>dougw</screen_name>
 
  <screen_name>dougw</screen_name>
 
  <location>San Francisco, CA</location>
 
  <location>San Francisco, CA</location>
  <description>Twitter API Support. Internet, greed, users, dougw and opportunities are my passions.</description>
+
  <description>Sina API Support. Internet, greed, users, dougw and opportunities are my passions.</description>
  <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/59648642/avatar_normal.png</profile_image_url>
+
  <profile_image_url>http://sinaimg.cn/avatar.png</profile_image_url>
 
  <url>http://www.igudo.com</url>
 
  <url>http://www.igudo.com</url>
 
  <protected>false</protected>
 
  <protected>false</protected>
第66行: 第58行:
 
  <utc_offset>-18000</utc_offset>
 
  <utc_offset>-18000</utc_offset>
 
  <time_zone>Eastern Time (US & Canada)</time_zone>
 
  <time_zone>Eastern Time (US & Canada)</time_zone>
  <profile_background_image_url>http://s3.amazonaws.com/twitter_production/profile_background_images/2752608/twitter_bg_grass.jpg</profile_background_image_url>
+
   
 
  <profile_background_tile>false</profile_background_tile>
 
  <profile_background_tile>false</profile_background_tile>
 
  <statuses_count>3394</statuses_count>
 
  <statuses_count>3394</statuses_count>
第93行: 第85行:
 
  <utc_offset>-18000</utc_offset>
 
  <utc_offset>-18000</utc_offset>
 
  <time_zone>Eastern Time (US & Canada)</time_zone>
 
  <time_zone>Eastern Time (US & Canada)</time_zone>
<profile_background_image_url>http://static.twitter.com/images/themes/theme1/bg.gif</profile_background_image_url>
 
 
  <profile_background_tile>false</profile_background_tile>
 
  <profile_background_tile>false</profile_background_tile>
 
  <statuses_count>382</statuses_count>
 
  <statuses_count>382</statuses_count>
第102行: 第93行:
 
  </direct_message>  
 
  </direct_message>  
  
===Usage examples: ===
+
===使用示例===
cURL (about cURL):
+
cURL:
  
 
curl -u user:password -d "text=all your bases are belong to us&user=user_2" http://api.t.sina.com.cn/direct_messages/new.xml
 
curl -u user:password -d "text=all your bases are belong to us&user=user_2" http://api.t.sina.com.cn/direct_messages/new.xml

2009年11月13日 (五) 18:07的版本

目录

发送私信

发送一条私信。必须包含参数user和text,请求必须使用POST方式提交。成功将返回完整的发送消息。

URL

http://api.t.sina.com.cn/direct_messages/new.format

格式

xml, json

HTTP请求方式

POST

是否需要身份验证

true

请求数限制

false

请求参数

  • user: 必须参数. UID或账户名. 为了支持数字的账户名,需选填写下面2个参数screen_name或user_id:
  • screen_name: 账户名
  • user_id: 新浪UID
  • text: 必须参数. 要发生的消息内容,需要做URLEncode,文本大小必须小于140个汉字.

使用说明

  • 此接口问更新受限接口,越权将返回http 403 错误
  • This method is subject to update limits. A HTTP 403 will be returned if this limit has been hit.

Response

XML示例:

<?xml version="1.0" encoding="UTF-8"?>
<direct_message>
<id>88619848</id>
<sender_id>1401881</sender_id>
<text>all your bases are belong to us.</text>
<recipient_id>7004322</recipient_id>
<created_at>Wed Apr 08 20:30:04 +0000 2009</created_at>
<sender_screen_name>dougw</sender_screen_name>
<recipient_screen_name>igudo</recipient_screen_name>
<sender>
<id>1401881</id>
<name>Doug Williams</name>
<screen_name>dougw</screen_name>
<location>San Francisco, CA</location>
<description>Sina API Support. Internet, greed, users, dougw and opportunities are my passions.</description>
<profile_image_url>avatar.png</profile_image_url>
<url>http://www.igudo.com</url>
<protected>false</protected>
<followers_count>1036</followers_count>
<profile_background_color>9ae4e8</profile_background_color>
<profile_text_color>000000</profile_text_color>
<profile_link_color>0000ff</profile_link_color>
<profile_sidebar_fill_color>e0ff92</profile_sidebar_fill_color>
<profile_sidebar_border_color>87bc44</profile_sidebar_border_color>
<friends_count>290</friends_count>
<created_at>Sun Mar 18 06:42:26 +0000 2007</created_at>
<favourites_count>0</favourites_count>
<utc_offset>-18000</utc_offset>
<time_zone>Eastern Time (US & Canada)</time_zone>

<profile_background_tile>false</profile_background_tile>
<statuses_count>3394</statuses_count>
<notifications>false</notifications>
<following>false</following>
<verified>true</verified>
</sender>
<recipient>
<id>7004322</id>
<name>Doug Williams</name>
<screen_name>igudo</screen_name>
<location>North Carolina</location> 
<description>A character.</description>
<profile_image_url>twitter_48_48_normal.jpg</profile_image_url>
<url>http://www.igudo.com</url>
<protected>false</protected>
<followers_count>19</followers_count>
<profile_background_color>69A1AA</profile_background_color>
<profile_text_color>000000</profile_text_color>
<profile_link_color>F00</profile_link_color>
<profile_sidebar_fill_color>ACBEC1</profile_sidebar_fill_color>
<profile_sidebar_border_color>8A8F85</profile_sidebar_border_color>
<friends_count>3</friends_count>
<created_at>Thu Jun 21 21:16:21 +0000 2007</created_at>
<favourites_count>0</favourites_count>
<utc_offset>-18000</utc_offset>
<time_zone>Eastern Time (US & Canada)</time_zone>
<profile_background_tile>false</profile_background_tile>
<statuses_count>382</statuses_count>
<notifications>false</notifications>
<following>true</following>
<verified>true</verified>
</recipient>
</direct_message> 

使用示例

cURL:

curl -u user:password -d "text=all your bases are belong to us&user=user_2" http://api.t.sina.com.cn/direct_messages/new.xml