Tag: facebook

在Facebook页面上发布的简便方法(不是个人资料,而是粉丝页面)

哪个选项是在Facebook页面上发布文本或其他内容的最佳和最简单的方法? 我正在寻找一种直接从我的Rails应用程序中添加内容的方法。 例如,单击按钮并自动在我的应用程序上发布并将数据发送到Facebook页面? 我为Twitter构建了一个,我的方法看起来像这样: def tweet(url) Twitter.configure do |config| config.consumer_key = APP_CONFIG[‘twitter_consumer_key’] config.consumer_secret = APP_CONFIG[‘twitter_consumer_secret’] config.oauth_token = APP_CONFIG[‘twitter_access_token’] config.oauth_token_secret = APP_CONFIG[‘twitter_secret_token’] end shorted_url = shorten_url(url) Twitter.update(“#{title} – #{shorted_url}”) end 谢谢。

测试Web应用程序与Cucumber的Facebook集成

我想通过执行以下场景来使用Cucumber和Capybara来测试我的Rails应用程序的Facebook注册过程: @javascript Scenario: Connect account When I go to the home page And I press “Connect your Facebook account” And I fill in “test@address” for “Email” And I fill in “test” for “Password” And I press “Login” And I press “Allow” Then I should be on the dashboard page 人们如何解决基于浏览器的Facebook集成的集成测试问题? 网络搜索只显示了几个早于图API的博客文章,他们似乎只讨论实现一个前提条件,即设置一个代表已登录到Facebook的用户的环境。 要解决的一些具体问题: 如何模拟单击元素? 我想出的最好的事情(但尚未测试)是手动触发元素上的click事件。 一旦Facebook对话框出现,Capybara可以访问它吗? […]

Ruby on Rails Omniauth facebook不会返回电子邮件

我一直在努力设置我的Omniauth for facebook我不知道我做错了什么。 我无法收到用户的电子邮件。 返回的哈希只包含“name”和“uid”,甚至不包含“first_name”和“last_name” devise.rb: config.omniauth :facebook, “KEY”, “SECRET” omn​​iauth_callbacks_controller.rb: class OmniauthCallbacksController < Devise::OmniauthCallbacksController def facebook logger.info request.env["omniauth.auth"] @user = User.from_omniauth(request.env["omniauth.auth"]) sign_in_and_redirect @user end end user.rb: class User [:facebook] has_many :authentications def self.from_omniauth(auth) logger.info auth user = where(email: auth.info.email).first if(user != nil) user.authentications.where(provider: auth.provider, uid: auth.uid).first_or_create do |l| user.authentications.create!(user_id: user.id, provider: auth.provider, uid: auth.uid) […]

Rails 4.1.5 omniauth强参数

将Rails 4.1.4升级到4.1.5后,我的facebook omniauth会话出错,从那时起一切正常。 当我创建一个用户会话时,我得到一个ActiveModel::ForbiddenAttributesError 路线: match ‘auth/:provider/callback’, to: ‘sessions#create’, as: ‘signin’, via: :get Session#创建控制器: def create user = User.from_omniauth(env[“omniauth.auth”]) session[:user_id] = user.id session[:user_name] = user.name redirect_to root_path end 和这样的用户模型: def self.from_omniauth(auth) where(auth.slice(:provider, :uid)).first_or_create.tap do |user| user.provider ||= auth.provider user.uid = auth.uid user.name = auth.info.name user.save end end 我可以通过添加许可来绕过ActiveModel错误! 我的用户模型中的方法是这样的: where(auth.slice(:provider, :uid).permit!).first_or_create.tap do |user| 但它覆盖数据库中的第一个用户… session[:user_id]似乎始终是数据库中的第一个用户。 […]

使用像facebook这样的omniauth提供程序时,Devise不会正确地重定向到存储位置

我在我的应用程序中有一些受保护的操作,需要用户身份validation。 因为我正在使用devise,所以我使用authenticate_user! 在过滤之前保护它们。 每当用户点击受保护的页面时,设计要求用户登录,然后重定向回受保护的页面。 这部分很完美。 问题是,当用户尝试通过我的应用程序登录Facebook时,设计在登录后不会将用户重定向到受保护的页面。 它总是将用户返回到根URL。 使用标准身份validation,这不是问题 我怀疑它与passthru方法有关 – 设计 – omniauth集成需要。 任何帮助将不胜感激 这是我的omniauth回调的代码片段: def facebook # You need to implement the method below in your model omniauth = request.env[“omniauth.auth”] @user = User.find_for_facebook_oauth(omniauth, current_user) if @user.persisted? flash[:notice] = I18n.t “devise.omniauth_callbacks.success”, :kind => “Facebook” sign_in_and_redirect @user, :event => :authentication else session[“devise.facebook_data”] = env[“omniauth.auth”] redirect_to new_user_registration_url […]

Omniauth:回调未触发,返回失败并显示“无效凭据”

我的Rails应用程序中使用Omniauth gem实现的facebook身份validation最近已停止工作。 问题是回调应该使用的控制器操作不会被触发,并且进程会立即跳过“无效凭据”消息而失败。 日志: Started GET “/auth/facebook” for ::ffff:127.0.0.1 at 2017-03-29 11:12:29 +0200 Started GET “/auth/facebook/callback?code=<>&state=<” for ::ffff:127.0.0.1 at 2017-03-29 11:12:30 +0200 Started GET “/auth/failure?message=invalid_credentials&origin=<>&strategy=facebook” for ::ffff:127.0.0.1 at 2017-03-29 11:12:31 +0200 Started GET “/login” for ::ffff:127.0.0.1 at 2017-03-29 11:12:31 +0200 Processing by UserSessionsController#new as HTML 路线: match “/auth/failure” => redirect(“/login”), :via => [:get, :post] match […]

输入的电子邮件覆盖SecureRandom电子邮件?

方法#1 Send email reminder to # :email belongs to the users table 方法#2 Send email reminder to # :default_email belongs to the challenges table. The point of this is to try something in the create process like current_user.email == @challenge.default_email 然后将用户重定向到signup url 如果用户通过Facebook注册,则会生成随机电子邮件,以便他可以完成validation过程: user.email = SecureRandom.hex + “@mailinator.com” user.rb def self.from_omniauth(auth) # Sets 60 day […]

在ROR应用程序中使用Facebook和OAuth登录时出错

伙计们,我放弃了。 我创建Rails应用程序,并希望登录Facebook。 我看看railscast,阅读一些教程以及关于stackoverflow的20多个问题…但我仍然无法在我的网站上使用fb登录..所以,请帮助我解决这个问题… 的Gemfile gem ‘omniauth-facebook’ gem ‘koala’, ‘~> 1.10.0rc’ 配置/初始化/ omniauth.rb OmniAuth.config.logger = Rails.logger Rails.application.config.middleware.use OmniAuth::Builder do provider :facebook, Rails.application.secrets[‘APP_ID’], Rails.application.secrets[‘APP_SECRET’], { scope: ‘user_about_me’ } end index.html.slim h2 Welcome = link_to ‘Login with Facebook’, ‘/auth/facebook’ Facebook – >开发者 – > MyApp – > Settigns Basic: 设置高级 在“使用Facebook登录”链接并在popap中确认后,我有错误: 应用程序配置不允许使用URL:应用程序的设置不允许使用一个或多个给定的URL。 它必须与网站URL或Canvas URL匹配,或者域必须是App域之一的子域。 有人可以解释我,Facebook或我的手有什么问题吗? 更新:好的,另一个错误:当Valid OAuth redirect […]

设计omniauth-facebook redirect_uriurl必须绝对

当我尝试将gem “omniauth-facebook”与设计集成时,我的Rails应用程序,我在facebook上收到以下错误: The redirect_uri URL must be absolute 。 以下是我的配置 devise.rb config.omniauth :facebook, “ID”, “SECRET”,callback_url: “/auth/facebook” 我的user.rb模型: class User [:facebook] def self.from_omniauth(auth) where(provider: auth.provider, uid: auth.uid).first_or_create do |user| user.email = auth.info.email user.password = Devise.friendly_token[0,20] user.name = auth.info.name # assuming the user model has a name user.image = auth.info.image # assuming the user model has an […]

使用Koala(Ruby)收集用户的新闻源

我想在经过身份validation后提取用户的新闻源。 我正在使用考拉gem,但如果我调用get_connection(‘me’, ‘feed’) ,它只返回我墙上的最后三个post。 我想要显示在用户主页上的最后约100个post(或自1234567后发布)。