DG beginning to collapse twitter&facebook
This commit is contained in:
parent
be39df75fe
commit
c489f49a25
7 changed files with 15 additions and 8 deletions
|
|
@ -45,15 +45,16 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
## take this out
|
||||||
def fb_user_info
|
def fb_user_info
|
||||||
if current_user
|
if current_user
|
||||||
@access_token = warden.session[:access_token]
|
@access_token = warden.session[:access_token]
|
||||||
@logged_in = @access_token.present?
|
@logged_in = @access_token.present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def logged_into_fb?
|
def logged_into_fb?
|
||||||
@logged_in
|
@logged_in
|
||||||
end
|
end
|
||||||
|
##
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ class OmniauthServicesController < ApplicationController
|
||||||
def create
|
def create
|
||||||
auth = request.env['omniauth.auth']
|
auth = request.env['omniauth.auth']
|
||||||
|
|
||||||
|
puts auth.inspect
|
||||||
|
|
||||||
access_token = auth['extra']['access_token']
|
access_token = auth['extra']['access_token']
|
||||||
user = auth['user_info']
|
user = auth['user_info']
|
||||||
current_user.services.create(:nickname => user['nickname'],
|
current_user.services.create(:nickname => user['nickname'],
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ class ServicesController < ApplicationController
|
||||||
code = params['code'] # Facebooks verification string
|
code = params['code'] # Facebooks verification string
|
||||||
if code
|
if code
|
||||||
access_token_hash = MiniFB.oauth_access_token(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create", FB_SECRET, code)
|
access_token_hash = MiniFB.oauth_access_token(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create", FB_SECRET, code)
|
||||||
p access_token_hash
|
|
||||||
@access_token = access_token_hash["access_token"]
|
@access_token = access_token_hash["access_token"]
|
||||||
|
|
||||||
# TODO: This is where you'd want to store the token in your database
|
# TODO: This is where you'd want to store the token in your database
|
||||||
|
|
|
||||||
|
|
@ -154,11 +154,12 @@ class User
|
||||||
intitial_post(class_name, aspect_ids, options)
|
intitial_post(class_name, aspect_ids, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def post_to_facebook(message, access_token)
|
def post_to_facebook(message)
|
||||||
id = 'me'
|
facebook = self.services.find_by_provider("facebook")
|
||||||
type = 'feed'
|
if facebook
|
||||||
Rails.logger.info("Sending a message: #{message} to Facebook")
|
Rails.logger.info("Sending a message: #{message} to Facebook")
|
||||||
EventMachine::HttpRequest.new("https://graph.facebook.com/me/feed?message=#{message}&access_token=#{access_token}").post
|
EventMachine::HttpRequest.new("https://graph.facebook.com/me/feed?message=#{message}&access_token=#{facebook.access_token}").post
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def post_to_twitter(message)
|
def post_to_twitter(message)
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,5 @@
|
||||||
= link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete
|
= link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete
|
||||||
|
|
||||||
= link_to "Connect to twitter", "/auth/twitter"
|
= link_to "Connect to twitter", "/auth/twitter"
|
||||||
|
= link_to "Connect to facebook", "/auth/facebook"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,6 @@
|
||||||
|
|
||||||
Rails.application.config.middleware.use OmniAuth::Builder do
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
||||||
provider :twitter, SERVICES['twitter']['consumer_key'], SERVICES['twitter']['consumer_secret']
|
provider :twitter, SERVICES['twitter']['consumer_key'], SERVICES['twitter']['consumer_secret']
|
||||||
#provider :facebook, 'APP_ID', 'APP_SECRET'
|
provider :facebook, SERVICES['facebook']['app_id'], SERVICES['facebook']['app_secret']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
twitter:
|
twitter:
|
||||||
consumer_key: no69jTnL5SCOnWgk5XWqbQ
|
consumer_key: no69jTnL5SCOnWgk5XWqbQ
|
||||||
consumer_secret: 2DZyu8DA43AIeFsRVdz8OtAHLvCtPjdRKdNO3UZGqWM
|
consumer_secret: 2DZyu8DA43AIeFsRVdz8OtAHLvCtPjdRKdNO3UZGqWM
|
||||||
|
facebook:
|
||||||
|
app_id: 120373411325347
|
||||||
|
app_secret: 7fe864834726f8a5e65bc93928b99a53
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue