简体   繁体   中英

Twit Send and Recieve Twitter DMs

I am trying to use Twit to send and recieve Twitter DMs.

When I create a stream like this:

var stream = T.stream('user');

I get a 404 error. I believe this is because the user stream has been deprecated.

What stream can I use instead to send and receive DMs?

That's correct, you will need to use the Account Activity API to receive Direct Messages in realtime. This is a webhook-based API. Twitter has a migration guide .

In summary:

  1. Create an app with a listening URL for Twitter to post events to.
  2. Register the webhook
  3. Listen for incoming Direct Messages
  4. Use the REST Direct Message API to respond.

There's also a full tutorial on this using a JavaScript package called autohook .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM