Direct messages/new
« Return to the list of API methods
Contents |
URL
http://yourserver/api/direct_messages/new.format
Description
It sends a private message to the specified user.
This method will return the info about the private message
Available formats
XML, JSON
HTTP Method
POST
Requires authentication
YES
Required parameters
- user: The user ID or username of the user you want to send the note. Example: http://yourserver/api/direct_messages/new.xml?user=2
- text: The text of the note you want to send. It's length has to be between 3 and 140 characters. Example: http://yourserver/api/direct_messages/new.xml?text=abcded
Optional parameters
- screen_name: The username of the user you want to send the note. Example: http://yourserver/api/direct_messages/new.json?screen_name=test
- user_id: The user ID of the user you want to send the note. Example: http://yourserver/api/direct_messages/new.xml?user_id=2
Return example (XML)
curl http://yourserver/api/direct_messages/new.xml -d "user=marcosgdf&text=abc"
<?xml version="1.0" encoding="UTF-8"?> <direct_message> <id>41</id> <created_at>Sun Apr 25 0:37:06 +0000 2010</created_at> <text>abc</text> <sender_id>1</sender_id> <recipient_id>1</recipient_id> <sender_screen_name>marcosgdf</sender_screen_name> <recipient_screen_name>marcosgdf</recipient_screen_name> <sender> <id>1</id> <name>marcosgdf</name> <screen_name>marcosgdf</screen_name> <location/> <description/> <profile_image_url>http://localhost/trunk/static/img/avatar/default_note.png</profile_image_url> <url/> <protected>true</protected> <followers_count>0</followers_count> <created_at>Fri Apr 16 20:12:11 +0000 2010</created_at> <favourites_count>0</favourites_count> <statuses_count>4</statuses_count> <friends_count>1</friends_count> <following>false</following> <utc_offset/> <geo_enabled>false</geo_enabled> <time_zone/> <profile_background_image_url>http://localhost/trunk/themes/transparency/img/bg.png</profile_background_image_url> <profile_background_tile>false</profile_background_tile> <notifications>false</notifications> <verified>false</verified> <lang>default</lang> <contributors_enabled>false</contributors_enabled> </sender> <recipient> <id>1</id> <name>marcosgdf</name> <screen_name>marcosgdf</screen_name> <location/> <description/> <profile_image_url>http://localhost/trunk/static/img/avatar/default_note.png</profile_image_url> <url/> <protected>true</protected> <followers_count>0</followers_count> <created_at>Fri Apr 16 20:12:11 +0000 2010</created_at> <favourites_count>0</favourites_count> <statuses_count>4</statuses_count> <friends_count>1</friends_count> <following>false</following> <utc_offset/> <geo_enabled>false</geo_enabled> <time_zone/> <profile_background_image_url>http://localhost/trunk/themes/transparency/img/bg.png</profile_background_image_url> <profile_background_tile>false</profile_background_tile> <notifications>false</notifications> <verified>false</verified> <lang>default</lang> <contributors_enabled>false</contributors_enabled> </recipient> </direct_message>
Return example (JSON)
curl http://yourserver/api/direct_messages/new.json -d "user=marcosgdf&text=abc"
{ "id": 39, "created_at": "Sun Apr 25 0:28:55 +0000 2010", "text": "abc", "sender_id": "1", "recipient_id": "1", "sender_screen_name": "marcosgdf", "recipient_screen_name": "marcosgdf", "sender": { "id": 1, "name": "marcosgdf", "screen_name": "marcosgdf", "location": null, "description": "", "profile_image_url": "http:\/\/localhost\/trunk\/static\/img\/avatar\/default_note.png", "url": null, "protected": true, "followers_count": "0", "created_at": "Fri Apr 16 20:12:11 +0000 2010", "favourites_count": 0, "statuses_count": "4", "friends_count": "1", "following": false, "utc_offset": null, "time_zone": null, "profile_background_image_url": "http:\/\/localhost\/trunk\/themes\/transparency\/img\/bg.png", "profile_background_tile": false, "notifications": false, "verified": false, "lang": "default", "contributions_enabled": false, "geo_enabled": false }, "recipient": { "id": 1, "name": "marcosgdf", "screen_name": "marcosgdf", "location": null, "description": "", "profile_image_url": "http:\/\/localhost\/trunk\/static\/img\/avatar\/default_note.png", "url": null, "protected": true, "followers_count": "0", "created_at": "Fri Apr 16 20:12:11 +0000 2010", "favourites_count": 0, "statuses_count": "4", "friends_count": "1", "following": false, "utc_offset": null, "time_zone": null, "profile_background_image_url": "http:\/\/localhost\/trunk\/themes\/transparency\/img\/bg.png", "profile_background_tile": false, "notifications": false, "verified": false, "lang": "default", "contributions_enabled": false, "geo_enabled": false } }

