推特 API 识别启用了直接消息传递的用户

twitter API identify users with direct messaging enabled

我正在尝试使用 twitter4j(在 Java 中)来获取关注特定用户的用户列表,这些用户碰巧启用了直接消息传递。像这样...

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();              
}

唯一的问题是我找不到与听起来合适的 twitter4j.User 对象关联的任何属性(而且在 API 文档中也找不到任何对它的引用)。有谁知道是否有某种方法可以通过编程方式找到这些类型的用户?或者推特故意排除了它?感谢您的任何想法。

-----编辑-----

Yuri 的文档 link 让我看到一位 Twitter 员工的回复:"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)

还注意到可以使用 "AccountSettings.getAccountSettings().allow_dms_from"

获取已通过身份验证的用户的 DM 状态

此处讨论

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

显然有一个您可以申请的访问白名单。

然而,您似乎基本上拥有了所需的一切。关注您帐户的用户通常已经可以收到您的 DM。这不包括用户首先与您私信或接受任何人私信的情况。

但尝试发送并检查失败可能是最简单的方法。