简体   繁体   English

要在Twitter上发帖,我是否也需要omniauth gem(以及twitter gem)?

[英]To post at twitter, do I need omniauth gem too (along with twitter gem)?

I am using devise and looking to post to twitter using "twitter" gem but I am little confused, do I also need omniauth gem too ? 我正在使用设计并希望使用“twitter”宝石发布到Twitter,但我有点困惑,我是否也需要omniauth gem? Do I need to configure omniauth with devise (I am using it for users) first before I can use "twitter" gem so users can post tweets 在我可以使用“twitter”gem之前,我是否需要首先使用devise配置omniauth(我正在为用户使用它),以便用户可以发布推文

EDIT - btw, it is the users which will be sending tweets to their respective tweeter accounts 编辑 - 顺便说一句,它是用户将发送推文到他们各自的tweeter帐户

Thanks 谢谢

No you don't need Omniauth gem, only twitter is enough 不,你不需要Omniauth宝石,只有twitter就足够了

This is what I did 这就是我做的

Gemfile 的Gemfile

gem 'twitter'

create your app from this url , and make sure you give your app the POST , permission 从此网址创建您的应用,并确保您的应用程序POST ,权限

config/initializers/twitter.rb 配置/初始化/ twitter.rb

Twitter.configure do |config|
  config.consumer_key = ""
  config.consumer_secret = ""
  config.oauth_token = ""
  config.oauth_token_secret = ""
end

then call it as 然后称之为

Twitter.update("I'm tweeting with @gem!")

on a side note, if you have any url to be shorten use bitly 在一个侧面说明,如果您有任何网址被缩短使用bitly

go to bitly and grab your access token 请小心翼翼地抓住你的访问令牌

Gem file 宝石文件

gem 'bitly' 宝石'有点'

and call it as 并称之为

bitly = Bitly.new("key", "key")
shorten_url = bitly.shorten("http://skylinelive.com")

HTH HTH

No, you don't need Omniauth to allow your users to post tweets. 不,您不需要Omniauth允许您的用户发布推文。 Omniauth is for authentication only -- that means logging into your website and creating user accounts. Omniauth仅用于身份验证 - 这意味着登录您的网站并创建用户帐户。

I could direct you better to what you need if you included info as to how the posting should work on your website. 如果您提供有关发布应如何在您的网站上运作的信息,我可以更好地指导您所需要的内容。 If all you want is to let them tweet a link to the current page, you need to include the code for the Tweet Button into the desired page. 如果您只想让他们发送指向当前页面的链接,则需要将Tweet按钮的代码包含在所需页面中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM