将 Rails 3 应用程序用户帐户连接到用户的 Twitter 帐户
我一直在寻找如何在我的 Rails 3 应用程序中简单地将用户的 id 连接到他们的 Twitter 帐户。我不希望用户使用 twitter 登录,我只是希望他们能够将他们的 twitter 帐户连接到 Rails 应用程序,这样我就可以使用特定的主题标签提取该用户的推文。
我发现以下教程推荐 twitter_oauth
gem:
- http://veerasundaravel.wordpress.com/2010/11/26/twitter-connection-in-rails-using-twitter_oauth-gem/
- http://franciscojsaez.tumblr.com/post/3363794466/connect-your-rails-app-to-twitter
之前的所以问题/答案 有点帮助,我一直在观看 Railscasts OmniAuth。不过我有点困惑。由于我没有使用 Twitter 登录,所以我不确定在哪里集成。这是在 UsersController
中处理的还是我需要像 Ryan 在 Railscast #235 中所做的那样创建一个 AuthenticationsController
?
任何帮助将不胜感激!
I've been searching for a while on how to simply connect a user's id to their twitter account in my Rails 3 app. I don't want users to login with twitter, I just want them to be able to connect their twitter account to the Rails app so I can pull in that user's tweets with a specific hashtag.
I found the following tutorials recommending the twitter_oauth
gem:
- http://veerasundaravel.wordpress.com/2010/11/26/twitter-connection-in-rails-using-twitter_oauth-gem/
- http://franciscojsaez.tumblr.com/post/3363794466/connect-your-rails-app-to-twitter
This prior SO question/answer helped a bit and I've been watching the Railscasts for OmniAuth. However I'm somewhat confused. Since I'm not logging in with twitter, I'm not sure where to integrate things. Is this handled in the UsersController
or do I need to create an AuthenticationsController
the way Ryan does in Railscast #235?
Any help would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来你的处理方式是错误的。如果您不需要通过 Twitter 登录他们,而只想查看他们的推文。
让他们输入 Twitter 用户名,然后只需进行 API 调用即可获取带有该主题标签的推文。
应该返回一个 json 对象,您可以进一步解析该对象以获得您需要的内容。
Twitter 搜索 API 的文档可以在这里找到:
https://dev.twitter.com/docs/using-search
Looks like you are going about this the wrong way. If you don't need to log them in through Twitter, and just want to get at their tweets.
Have them pop in their twitter username, then just make an API call to get their tweets with that hashtag.
should return a json object that you can further parse to get what you need.
The documentation for the Twitter search API can be found here:
https://dev.twitter.com/docs/using-search