Skip to content

Instantly share code, notes, and snippets.

@chrismear
Created September 3, 2008 16:16
Show Gist options
  • Save chrismear/8617 to your computer and use it in GitHub Desktop.
Save chrismear/8617 to your computer and use it in GitHub Desktop.
# Create a model to save in-progress ContactSiphon sessions:
# script/generate contact_siphon_sessions
# rake db:migrate
# config/contact_siphon.yml:
windows_live_mail:
return_url: http://www.example.com/windows_live
privacy_policy_url: http://www.example.com/privacy
secret_key: dofinsoiaosdifnaosdnf
yahoo_mail:
application_id: 1203981209382
shared_secret: 12b3fa12b3f1b2fa3
gmail:
oauth_consumer_key: www.example.com
oauth_consumer_secret: cbfc5bf2cbf3c1b2c
x509_key_file: config/google_x509_key.pem
# MyController:
class MyController < ApplicationController
contact_siphon_for :gmail, :yahoo_mail, :windows_live_mail
# This creates the actions:
#
# gmail_start
# gmail_return
# yahoo_mail_start
# yahoo_mail_return
# windows_live_start
# windows_live_return
#
# Send your user to the appropriate _start action, and ContactSiphon
# will set things up and redirect them to the service provider
# for authorization.
#
# Set up your return URL for each service provider so that the user
# gets sent back to the appropriate _return action, and ContactSiphon
# will grab the parameters it needs, fetch the contacts into @contacts,
# and pass control to the 'contact_siphon_return' method, which you
# provide:
def contact_siphon_return
# Do what you like here with the @contact variable
render(:text => @contacts.inspect)
# => {'Bob Smith' => 'bob@example.com', 'Sue Jenkins' => 'sue@example.org}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment