Class: SocialButterfly::Services::FacebookService

Inherits:
AbstractService show all
Defined in:
lib/social_butterfly/services/facebook_service.rb

Class Method Summary collapse

Methods inherited from AbstractService

share

Class Method Details

.share_button_url(content, service_options = {}) ⇒ Object



5
6
7
# File 'lib/social_butterfly/services/facebook_service.rb', line 5

def self.share_button_url(content, service_options={})
  "https://www.facebook.com/sharer/sharer.php?u=#{content[:url]}"
end

.track(content, service_options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/social_butterfly/services/facebook_service.rb', line 9

def self.track(content, service_options={})
  url = "http://graph.facebook.com/#{content[:url]}"
  stats = {}
  result = JSON.parse(open(url).read)

  if result.present? && result['shares'].present?
    stats[:shares] = result['shares']
  else
    stats[:shares] = 0
  end
  stats
end