Module: Socialyzer

Defined in:
lib/socialyzer.rb,
lib/socialyzer/engine.rb,
lib/socialyzer/version.rb

Defined Under Namespace

Classes: Engine

Constant Summary collapse

API_KEY =
SOCIALYZER_API_KEY
VERSION =
"0.0.9"

Class Method Summary collapse

Class Method Details

.add_twitter_user(screen_name, options = {}) ⇒ Object



12
13
14
# File 'lib/socialyzer.rb', line 12

def self.add_twitter_user(screen_name, options={})
  api_request(:add_twitter_account, options.merge(:user => screen_name))
end

.api_action(action, env = :production) ⇒ Object



53
54
55
# File 'lib/socialyzer.rb', line 53

def self.api_action(action, env=:production)
  "#{Socialyzer::BASE_URL}/api/#{action}.json"
end

.api_request(action, options = {}) ⇒ Object



46
47
48
49
50
51
# File 'lib/socialyzer.rb', line 46

def self.api_request(action, options={})
  env = options.delete(:env) || :production
  options.merge!(:key => API_KEY)
  res = RestClient.post api_action(action, env), options.to_json, :content_type => :json, :accept => :json
  JSON.parse(res)
end


36
37
38
# File 'lib/socialyzer.rb', line 36

def self.bitly_links(screen_name)
  api_request(:bitly_links, :user => screen_name)
end

.bulk_add_twitter_account(options = {}) ⇒ Object

Not really supported yet



42
43
44
# File 'lib/socialyzer.rb', line 42

def self.(options={})
  api_request(:bulk_add_twitter_account, options)
end

.daily_best(screen_name) ⇒ Object



32
33
34
# File 'lib/socialyzer.rb', line 32

def self.daily_best(screen_name)
  api_request(:daily_best, :user => screen_name)["schedule"]
end

.optimize(screen_name, options = {}) ⇒ Object



16
17
18
# File 'lib/socialyzer.rb', line 16

def self.optimize(screen_name, options={})
  api_request(:optimize, options.merge(:user => screen_name))
end

.optimize_facebook(options = {}) ⇒ Object



24
25
26
# File 'lib/socialyzer.rb', line 24

def self.optimize_facebook(options={})
  api_request(:optimize_facebook, options)
end

.optimize_twitter(screen_name, options = {}) ⇒ Object



20
21
22
# File 'lib/socialyzer.rb', line 20

def self.optimize_twitter(screen_name, options={})
  optimize(screen_name, options)
end

.twitter_user(screen_name) ⇒ Object



28
29
30
# File 'lib/socialyzer.rb', line 28

def self.twitter_user(screen_name)
  api_request(:twitter_user, :user => screen_name)["twitter_user"]
end