1

I have some problem with Omnicontacts gem in RoR. It always return empty array when I import friends from Gmail. My config/omnicontacts.rb:

 require 'omnicontacts'

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

Code for 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

Help me please! Thanks!

dshevc93
  • 141
  • 1
  • 1
  • 11

1 Answers1

0

I believe that:

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

Should actually be

importer :facebook, "client_id", "client_secret"

Looking at the docs I don't see a need for the :redirect_path when dealing with facebook. Also it is not a good idea to publish your client_id and client_secret on public forums.

louiedp3
  • 78
  • 6
  • Also how are you testing this. Facebook does not allow usage of localhost so you might have to use ngrok. https://github.com/Diego81/omnicontacts#working-on-localhost – louiedp3 Jul 10 '14 at 16:35