Permalink
Browse files

tweaked the README

  • Loading branch information...
1 parent 63fb70d commit 1a43b3a0a43ac020c60688e3bacd9282ee6d071a @Diego81 committed May 10, 2012
View
@@ -2,3 +2,4 @@ coverage
*.iml
.idea
.DS_Store
+nbproject
View
@@ -36,8 +36,16 @@ On the other hand it makes things much easier to leave the default value for `:r
## Integrating with your Application
-To use OmniContacts you only need to redirect users to `/contacts/:importer`, where `:importer` can be google, yahoo or hotmail. Once the user has authorized your application, he will be redirected back to your website, to the path specified in `:redirect_path` (or `:callback_path` for yahoo). The user is redirected to `/contacts/:importer/callback` by default, which therefore makes things much simpler to not specify any value for `:redirect_path` or `:callback_path`.
-The list of contacts can be accessed via the `omnicontacts.contacts` key in the environment hash. The list of contacts is a simple array of hashes. Each hash has two keys: `:email` and `:name`, containing the email and the name of the contact respectively.
+To use the Gem you first need to redirect users to `/contacts/:importer`, where `:importer` can be google, yahoo or hotmail.
+No changes to `config/routes.rb` are needed for this step since OmniContacts will be listening on that path and redirect the user to the email provider's website in order to authorize your app to access his contact list.
+Once that is done the user will be redirected back to your application, to the path specified in `:redirect_path` (or `:callback_path` for yahoo).
+If nothing is specified the default value is `/contacts/:importer/callback` (e.g. `/contacts/yahoo/callback`). This makes things simpler and you can just add the following line to `config/routes.rb`:
+
+```ruby
+ match "/contacts/:importer/callback" => "your_controller#callback"
+```
+
+The list of contacts can be accessed via the `omnicontacts.contacts` key in the environment hash. It is a simple array of hashes. Each hash has two keys: `:email` and `:name`, containing the email and the name of the contact respectively.
```ruby
def contacts_callback
@@ -27,13 +27,13 @@ def authorization_url
def authorize_url_params
to_query_string({
- :client_id => client_id,
- :scope => encode(scope),
- :response_type => "code",
- :access_type => "offline",
- :approval_prompt => "force",
- :redirect_uri => encode(redirect_uri)
- })
+ :client_id => client_id,
+ :scope => encode(scope),
+ :response_type => "code",
+ :access_type => "offline",
+ :approval_prompt => "force",
+ :redirect_uri => encode(redirect_uri)
+ })
end
public
@@ -18,7 +18,7 @@ def initialize app, consumer_key, consumer_secret, options = {}
super app, options
@consumer_key = consumer_key
@consumer_secret = consumer_secret
- @callback_path = options[:callback_path] ||= "/contacts/#{class_name}/callback"
+ @callback_path = options[:callback_path] || "/contacts/#{class_name}/callback"
@token_prop_name = "#{base_prop_name}.oauth_token"
end
@@ -19,7 +19,7 @@ def initialize app, client_id, client_secret, options ={}
super app, options
@client_id = client_id
@client_secret = client_secret
- @redirect_path = options[:redirect_path] ||= "/contacts/#{class_name}/callback"
+ @redirect_path = options[:redirect_path] || "/contacts/#{class_name}/callback"
@ssl_ca_file = options[:ssl_ca_file]
end

0 comments on commit 1a43b3a

Please sign in to comment.