twitter API识别启用了直接消息传递的用户(twitter API identify users with direct messaging enabled)

编程入门 行业动态 更新时间:2024-10-25 11:23:19
twitter 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文档中也找不到对它的任何引用)。 有谁知道有没有办法以编程方式找到这些类型的用户? 或者也许twitter故意排除它? 谢谢你的任何想法。

- - - 编辑 - - -

来自Yuri的文档链接让我得到了来自Twitter员工的回复:“确定用户是否接受所有DM,无法通过公共API获得。如果您是值得信赖的合作伙伴,请通过您的直接Twitter联系人联系以获取详细信息。” ( 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状态。

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"

最满意答案

这在这里讨论

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

显然您可以申请访问白名单。

然而,似乎你大部分都拥有你需要的一切。 关注您帐户的用户通常可以从您那里收到DM。 这不包括用户首先使用DM,或接受任何人的DM的情况。

但尝试发送和检查故障可能是最简单的。

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.

更多推荐

本文发布于:2023-08-04 16:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1417797.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消息   用户   twitter   API   identify

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!