d3wannabe
d3wannabe

Reputation: 1317

twitter API identify users with direct messaging enabled

I'm trying to use twitter4j (in Java) to grab the list of users following a particular user who happen to have direct messaging enabled. Something like this...

IDs followerIDs = twitter.getFollowersIDs(someTwitterScreenName, -1); 
long[] ids = followerIDs.getIDs(); 
for (long id : ids) {

    twitter4j.User user = twitter.showUser(id); 

    String userScreenName = user.getScreenName();
    String realName = user.getName();

    //I'm hoping for something like...
    ///Boolean directMessagingEnabled = user.messagingEnabled();              
}

The only problem is that I can't find any attributes associated with the twitter4j.User object that sound suitable (and also can't find any reference to it in the API documentation). Does anyone know if there's some way to programmatically find these types of users? Or perhaps twitter have deliberately excluded it? Thanks for any thoughts at all.

------EDIT-----

The documentation link from Yuri led me to this response from a twitter employee: "Determining if a user accepts DMs from all is not available via the public API. If you are a trusted partner please reach out via your direct Twitter contacts for details." (https://twittercommunity.com/t/how-can-i-tell-which-users-the-current-user-can-send-messages-to/36127/4)

Also noticed that it IS possible to get the DM status for an already authenticated user using "AccountSettings.getAccountSettings().allow_dms_from"

Upvotes: 0

Views: 201

Answers (1)

Yuri Schimke
Yuri Schimke

Reputation: 13448

This is discussed here

https://dev.twitter.com/rest/reference/post/direct_messages/new

There is apparently a whitelist for access you can apply for.

However it seems you mostly have all you need. The users following your account can usually receive DMs from you already. This doesn't cover the cases where the user either DMed you first, or accepts DMs from anyone.

But it is probably simplest to try sending and inspect the failures.

Upvotes: 1

Related Questions