サイトのトップへ戻る

Twitter 開発者 ドキュメント日本語訳

POST direct_messages/new

認証ユーザーから指定したユーザーへ新しいダイレクトメッセージを送信します。 ユーザーを表すパラメータとtextパラメータの両方をPOSTしなければなりません。成功した場合、送信メッセージが、リクエストした形式で返されます。



ダイレクトメッセージの動作

Twitter でダイレクトメッセージを使用するには、受信者が送信者をフォローしている必要があります。ほとんどの場合、自分をフォローしていない相手にダイレクトメッセージを送ると相手に届かずエラーメッセージが返ります。

あるいは、受信者がallow_dms_fromアカウント設定を“all.”に設定していた場合は、受信者が送信者をフォローしているかどうかに関わらずダイレクトメッセージは受信者に届きます。

ユーザー間でダイレクトメッセージのスレッドが確立されると、フォロー関係に関わらず、このスレッドは使って双方向にメッセージを送り合うことができます。 To discontinue the thread (effectively, leave the conversation), it is necessary to either explicitly leave the conversation in the Twitter client/website or perform a block of the user via the APIs or Twitter client/website.

注意

friendships/lookupを使ってユーザー間のフォロー状態を調べる以外に、ユーザーへダイレクトメッセージを送れるかどうかを判別するpublic APIはありません。あなたのアプリでこのような動作が必要な場合は、このフォームを使用してホワイトリストへのアクセスを申請することができます。あなたの使用ケースは審査され、全ての申請が許可されるとは限りません。 Your app may always attempt to send the Direct Message and handle any errors gracefully.


リソースURL

https://api.twitter.com/1.1/direct_messages/new.json



リソース情報

応答形式
JSON
認証は必要ですか?
はい (user context only)
レート制限はありますか?
はい


パラメータ

user_idscreen_nameのうちいずれか一つは必ず設定してください。

user_id 任意

ダイレクトメッセージを受信するユーザーのID。ユーザーIDとスクリーンネームが同じ場合に、どちらを指定しているのか明確にするために使います。

サンプル値: 12345

screen_name 任意

ダイレクトメッセージを受信するユーザーのスクリーンネーム。スクリーンネームとユーザーIDが同じ場合に、どちらを指定しているのか明確にするために使います。

サンプル値: noradio

text 必須

ダイレクトメッセーのテキスト。必要であれば URL エンコードをし、メッセージは140字未満にしてください。

サンプル値: Meet me behind the cafeteria after school



OAuth 署名ジェネレータ

ログインして登録アプリケーションの一覧を参照してください。



リクエスト例

POST

https://api.twitter.com/1.1/direct_messages/new.json?text=hello%2C%20tworld.%20welcome%20to%201.1.&screen_name=theseancook



応答結果の例


{
    "created_at": "Tue Aug 28 00:59:49 +0000 2012", 
    "entities": {
        "hashtags": [], 
        "urls": [], 
        "user_mentions": []
    }, 
    "id": 240252311455277056, 
    "id_str": "240252311455277056", 
    "recipient": {
        "contributors_enabled": true, 
        "created_at": "Sat May 09 17:58:22 +0000 2009", 
        "default_profile": false, 
        "default_profile_image": false, 
        "description": "I taught your phone that thing you like.  The Mobile Partner Engineer @Twitter. ", 
        "favourites_count": 584, 
        "follow_request_sent": false, 
        "followers_count": 10622, 
        "following": true, 
        "friends_count": 1181, 
        "geo_enabled": true, 
        "id": 38895958, 
        "id_str": "38895958", 
        "is_translator": false, 
        "lang": "en", 
        "listed_count": 190, 
        "location": "San Francisco", 
        "name": "Sean Cook", 
        "notifications": false, 
        "profile_background_color": "1A1B1F", 
        "profile_background_image_url": "http://a0.twimg.com/profile_background_images/495742332/purty_wood.png", 
        "profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/495742332/purty_wood.png", 
        "profile_background_tile": true, 
        "profile_image_url": "http://a0.twimg.com/profile_images/1751506047/dead_sexy_normal.JPG", 
        "profile_image_url_https": "https://si0.twimg.com/profile_images/1751506047/dead_sexy_normal.JPG", 
        "profile_link_color": "2FC2EF", 
        "profile_sidebar_border_color": "181A1E", 
        "profile_sidebar_fill_color": "252429", 
        "profile_text_color": "666666", 
        "profile_use_background_image": true, 
        "protected": false, 
        "screen_name": "theSeanCook", 
        "show_all_inline_media": true, 
        "statuses_count": 2608, 
        "time_zone": "Pacific Time (US & Canada)", 
        "url": null, 
        "utc_offset": -28800, 
        "verified": false
    }, 
    "recipient_id": 38895958, 
    "recipient_screen_name": "theSeanCook", 
    "sender": {
        "contributors_enabled": false, 
        "created_at": "Thu Aug 23 19:45:07 +0000 2012", 
        "default_profile": false, 
        "default_profile_image": false, 
        "description": "Keep calm and test", 
        "favourites_count": 0, 
        "follow_request_sent": false, 
        "followers_count": 0, 
        "following": false, 
        "friends_count": 11, 
        "geo_enabled": true, 
        "id": 776627022, 
        "id_str": "776627022", 
        "is_translator": false, 
        "lang": "en", 
        "listed_count": 0, 
        "location": "San Francisco, CA", 
        "name": "Mick Jagger", 
        "notifications": false, 
        "profile_background_color": "000000", 
        "profile_background_image_url": "http://a0.twimg.com/profile_background_images/644522235/cdjlccey99gy36j3em67.jpeg", 
        "profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/644522235/cdjlccey99gy36j3em67.jpeg", 
        "profile_background_tile": true, 
        "profile_image_url": "http://a0.twimg.com/profile_images/2550256790/hv5rtkvistn50nvcuydl_normal.jpeg", 
        "profile_image_url_https": "https://si0.twimg.com/profile_images/2550256790/hv5rtkvistn50nvcuydl_normal.jpeg", 
        "profile_link_color": "000000", 
        "profile_sidebar_border_color": "000000", 
        "profile_sidebar_fill_color": "000000", 
        "profile_text_color": "000000", 
        "profile_use_background_image": false, 
        "protected": false, 
        "screen_name": "s0c1alm3dia", 
        "show_all_inline_media": false, 
        "statuses_count": 0, 
        "time_zone": "Pacific Time (US & Canada)", 
        "url": "http://cnn.com", 
        "utc_offset": -28800, 
        "verified": false
    }, 
    "sender_id": 776627022, 
    "sender_screen_name": "s0c1alm3dia", 
    "text": "hello, tworld. welcome to 1.1."
}