DG beginning to collapse twitter&facebook

This commit is contained in:
maxwell 2010-10-25 13:59:26 -07:00 committed by danielvincent
parent be39df75fe
commit c489f49a25
7 changed files with 15 additions and 8 deletions

View file

@ -45,15 +45,16 @@ class ApplicationController < ActionController::Base
end
end
## take this out
def fb_user_info
if current_user
@access_token = warden.session[:access_token]
@logged_in = @access_token.present?
end
end
def logged_into_fb?
@logged_in
end
##
end

View file

@ -13,6 +13,8 @@ class OmniauthServicesController < ApplicationController
def create
auth = request.env['omniauth.auth']
puts auth.inspect
access_token = auth['extra']['access_token']
user = auth['user_info']
current_user.services.create(:nickname => user['nickname'],

View file

@ -12,7 +12,6 @@ class ServicesController < ApplicationController
code = params['code'] # Facebooks verification string
if 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"]
# TODO: This is where you'd want to store the token in your database

View file

@ -154,11 +154,12 @@ class User
intitial_post(class_name, aspect_ids, options)
end
def post_to_facebook(message, access_token)
id = 'me'
type = 'feed'
def post_to_facebook(message)
facebook = self.services.find_by_provider("facebook")
if 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
def post_to_twitter(message)

View file

@ -15,4 +15,5 @@
= link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete
= link_to "Connect to twitter", "/auth/twitter"
= link_to "Connect to facebook", "/auth/facebook"

View file

@ -4,6 +4,6 @@
Rails.application.config.middleware.use OmniAuth::Builder do
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

View file

@ -1,3 +1,6 @@
twitter:
consumer_key: no69jTnL5SCOnWgk5XWqbQ
consumer_secret: 2DZyu8DA43AIeFsRVdz8OtAHLvCtPjdRKdNO3UZGqWM
facebook:
app_id: 120373411325347
app_secret: 7fe864834726f8a5e65bc93928b99a53