Twitter 上确认 关注

发布于 2024-08-23 11:33:51 字数 243 浏览 15 评论 0原文

我是 twitter API 的新手 https://dev.twitter.com/docs/api 我想激励我网站上的用户关注我,或者通过在我的网站上给予他们额外的权限来转发我的推文(如果他们这样做)。为了做到这一点,我需要在他们关注我或转发等后进行某种类型的确认。这可能吗?实用吗?如果是这样,有人能指出我正确的方向吗?

I'm new to the twitter API https://dev.twitter.com/docs/api and I would like to incentivize users on my website to follow me, or re-tweet me by giving them extra privileges on my site if they do. In order to do this, I need some type of confirmation after they have followed me, or retweeted, etc. Is this possible, or practical? If so can anyone point me in the right direction?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七婞 2024-08-30 11:33:51

是的,这是合理的。从他们的 API 文档(参见#1)中,您可以发出关注者请求,用您的 Twitter 用户名替换 USERNAME:

http://api.twitter.com/1/statuses/followers/USERNAME.xml?cursor=-1

我只需存储该用户列表,需要时,定期提出新请求,以了解您是否有其他关注者。看起来是按照从最新到最新的顺序排列的,因此您可能只需要请求一两页。

在 XPath 表示法中,您会对 /users/user 节点感兴趣,也许具体来说,/users/user/screen_name[text() = 'provided_username']

有了这些信息,您就可以调整您的网站行为。

1: "http://apiwiki.twitter.com/Twitter-REST-API-Method:-statuses followers"

注意: markdown 似乎破坏了上述 URL 中的空格,并且对空格进行 URL 编码会导致 404。

Yeah, that's reasonable. From their API Documentation (see #1), you can make a followers request, substituting USERNAME with your twitter username:

http://api.twitter.com/1/statuses/followers/USERNAME.xml?cursor=-1

I'd simply store that list of users and, when needed, make periodic new requests to find out if you have additional followers. It looks like it's in order from most recent to newest, so you'd likely only need to request a page or two.

In XPath notation, you'll be interested in the /users/user nodes, and perhaps specifically, /users/user/screen_name[text() = 'provided_username'].

Armed with that information, you can then tweek your website behaviors.

1: "http://apiwiki.twitter.com/Twitter-REST-API-Method:-statuses followers"

Note: markdown seems to break on the space in the above URL, and URL-encoding the space results in a 404.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文