Twitter 上确认 关注
我是 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这是合理的。从他们的 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']
。有了这些信息,您就可以调整您的网站行为。
注意: 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.
Note: markdown seems to break on the space in the above URL, and URL-encoding the space results in a 404.