본문 바로가기

Story/api/연동

Twitter Developers - API Updates for Direct Messages Rules

반응형

Today we’re updating the Direct Messages experience1 on the Twitter iPhone app, Android app and Twitter.com to enable users to create private conversations on Twitter more easily. More specifically, we are giving users the option to receive DMs from anyone, and to always be able to reply once a message is received.

We believe these features are useful for a variety of use cases. Journalists and newsrooms can open up a more private, direct relationship to their viewers and constituencies. Likewise, brands can offer their customers faster and more responsive support.

These changes will be reflected via the API as well, with no additional development necessary on your part. When sending DMs, the API will simply respect the user’s setting of accept/don’t accept DMs from anyone.

A few specific behaviors in the API to note, for advanced developers:

  • The account settings object has an allow_dms_from field which
    indicates who can DM a user, either in a private one-on-one thread or
    in a group thread. Possible values include “following” (only users
    you are following are allowed to DM you) and “anyone” (allow any user
    on Twitter to DM you).

  • The API endpoint /account/settings.json allows the logged in user to
    set the values for allow_dms_from. This endpoint returns the
    current values as well. Editing this permission requires the “Read,
    Write and Access direct messages” permission in you app. An example request and response are below.

  • To prevent DMs from a particular user, you must block that user. This
    removes the user-to-user association on our side, preventing future
    DMs. A following un-block will still respect the no-DM state.un-block
    will still respect the no-DM state.

Updates to dev.twitter.com documentation to come shortly.

POST Request:

https://api.twitter.com/1.1/account/settings.json?allow_dms_from=anyone

HTTP Response:

{
  "sleep_time": {
    "end_time": null,
    "enabled": false,
    "start_time": null
  },
  "use_cookie_personalization": true,
  "trend_location": [{
    "name": "San Francisco",
    "placeType": {
    "name": "Town",
    "code": 7
  },{
    "woeid": 2487956,
    "country": "United States",
    "url": "http://where.yahooapis.com/v1/place/2487956",
    "countryCode": "US",
    "parentid": 23424977
  }],
  "language": "en",
  "discoverable_by_email": true,
  "always_use_https": true,
  "protected": false,
  "geo_enabled": true,
  "show_all_inline_media": false,
  "screen_name": "oauth_dancer",
  "allow_dms_from": "anyone"
}

 

출처 : https://twittercommunity.com/t/api-updates-for-direct-messages-rules/36061

반응형