Skip to content

Instantly share code, notes, and snippets.

@vinhnglx
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinhnglx/2963a4e17b928161ac43 to your computer and use it in GitHub Desktop.
Save vinhnglx/2963a4e17b928161ac43 to your computer and use it in GitHub Desktop.
Using Omnicontacts to get mail contacts from Google ref: http://qiita.com/vinhnguyenleasnet/items/53ade9f730d21a7a84d4
<% unless @contacts.nil?%>
<% @contacts.each do |c|%>
<ul>
<li><%= c[:name]%> : <%= c[:email]%></li>
</ul>
<%end%>
<%end%>
mkdir omnicontacts
cd omnicontacts/
rails new .
gem 'omnicontacts'
gem 'omnicontacts'
class MainController < ApplicationController
def index
end
def contact
end
end
class MainController < ApplicationController
def index
end
def contact
end
end
require 'omnicontacts'
Rails.application.middleware.use OmniContacts::Builder do
importer :gmail, "client_id", "client_secret, {:redirect_path => "/oauth2callback", :ssl_ca_path => "/etc/ssl/certs/curl-ca-bundle.crt"}
end
require 'omnicontacts'
Rails.application.middleware.use OmniContacts::Builder do
importer :gmail, "client_id", "client_secret, {:redirect_path => "/oauth2callback", :ssl_ca_path => "/etc/ssl/certs/curl-ca-bundle.crt"}
end
Omnicontacts::Application.routes.draw do
match "/contacts/:importer/callback" => "main#index", :via => [:get]
match "/oauth2callback" => "main#contact", :via => [:get]
# You can have the root of your site routed with "root"
root 'main#index'
end
Omnicontacts::Application.routes.draw do
match "/contacts/:importer/callback" => "main#index", :via => [:get]
match "/oauth2callback" => "main#contact", :via => [:get]
# You can have the root of your site routed with "root"
root 'main#index'
end
class MainController < ApplicationController
def index
end
def contact
@contacts = request.env['omnicontacts.contacts']
respond_to do |format|
format.html
end
end
end
<h2>OmniContacts Example</h2>
<a href="/contacts/gmail">Gmail</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment