ruby on rails - Omnicontacts返回@friends的空数组

时间:2014-07-10 15:18:34

标签: ruby-on-rails ruby omnicontacts-gem

我在RoR中遇到Omnicontacts gem的问题。当我从Gmail导入朋友时,它总是返回空数组。 我的config/omnicontacts.rb

 require 'omnicontacts'

 Rails.application.middleware.use OmniContacts::Builder do
  importer :gmail, "775603091912-87u7d1bqgjrbsau8mtonb1pgp8nao386.apps.googleusercontent.com", 
                   "j3ymIJ0l3kEkGycqUzqkt-dJ"
 end

OmniContactsController的代码:

  class InvitesController < ApplicationController

  def contact_callback
    @contacts = request.env['omnicontacts.contacts']
    @user = request.env['omnicontacts.user']
    puts "List of contacts of #{user[:name]} obtained from #params[:importer]}:"
    @contacts.each do|contact|
      puts "Contact found: name => #{contact[:name]}, email => #{contact[:email]}"
    end
  end

  def index
    @contacts = request.env['omnicontacts.contacts']
    respond_to do |format|
      format.html
    end
  end

end

的routes.rb

Rails.application.routes.draw do
  get "/invites/:provider/contact_callback" => "invites#index"
  get "/contacts/failure" => "invites#failure"
end

请帮帮我! 谢谢!

1 个答案:

答案 0 :(得分:0)

我相信:

importer :facebook, "client_id", "client_secret", {
         :redirect_path => "/contacts/facebook/callback"
}

实际应该是

importer :facebook, "client_id", "client_secret"

查看文档时,我认为在处理Facebook时不需要:redirect_path。在公共论坛上发布client_id和client_secret也不是一个好主意。