Class: FacebookApp::FacebookCredentials

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/facebook_app/facebook_credentials.rb

Class Method Summary collapse

Class Method Details

.advertising_urlObject



26
27
28
# File 'app/models/facebook_app/facebook_credentials.rb', line 26

def advertising_url
  app_url + "?marketing_mode=advertising"
end

.app_access_tokenObject



34
35
36
# File 'app/models/facebook_app/facebook_credentials.rb', line 34

def app_access_token
  current_credentials.app_access_token || register_app_access_token
end

.app_idObject



18
19
20
# File 'app/models/facebook_app/facebook_credentials.rb', line 18

def app_id
  current_credentials.app_id
end

.app_urlObject



43
44
45
# File 'app/models/facebook_app/facebook_credentials.rb', line 43

def app_url
  current_credentials.app_url
end

.current_credentialsObject



55
56
57
58
59
60
61
62
63
64
# File 'app/models/facebook_app/facebook_credentials.rb', line 55

def current_credentials
  if count == 0
    seed_initial_credentials
  end
  if Rails.env.development?
    last_development_config.last
  else
    last_production_config.last
  end
end

.emailObject



47
48
49
# File 'app/models/facebook_app/facebook_credentials.rb', line 47

def email 
  current_credentials.email
end

.passwordObject



51
52
53
# File 'app/models/facebook_app/facebook_credentials.rb', line 51

def password
  current_credentials.password
end

.register_app_access_tokenObject



38
39
40
41
# File 'app/models/facebook_app/facebook_credentials.rb', line 38

def register_app_access_token
  oauth = Koala::Facebook::OAuth.new(FacebookApp::FacebookCredentials.app_id, FacebookApp::FacebookCredentials.secret)
  FacebookApp::FacebookCredentials.current_credentials.update_attribute(:app_access_token, oauth.get_app_access_token)
end

.secretObject



30
31
32
# File 'app/models/facebook_app/facebook_credentials.rb', line 30

def secret
  current_credentials.secret
end

.seed_initial_credentialsObject



13
14
15
16
# File 'app/models/facebook_app/facebook_credentials.rb', line 13

def seed_initial_credentials 
  create(:development => true, :app_id => "225198020866871", :secret => "c13ca68717af076f6832f4d38a6da48a", :app_url => "http://apps.facebook.com/the-better-frienddev", :email => "[email protected]", :password => "notteling" )
  create(:development => false, :app_id => "178965915518857", :secret => "928b9a0edf812a236499bcc99da7a4bc", :app_url => 'https://apps.facebook.com/truthcanhurt', :email => "dummydata", :password => "dummydata")
end

.viral_urlObject



22
23
24
# File 'app/models/facebook_app/facebook_credentials.rb', line 22

def viral_url
  app_url + "?marketing_mode=viral"
end