Class: SocialButterfly::Services::TwitterService

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

Class Method Summary collapse

Methods inherited from AbstractService

share

Class Method Details

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



5
6
7
8
9
10
11
# File 'lib/social_butterfly/services/twitter_service.rb', line 5

def self.share_button_url(content, service_options={})
  "http://twitter.com/share?" +
    "url=" + content[:url] +
    "&text=" + content[:text] +
    "&via=" + service_options[:via] +
    "&count=none"
end

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



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/social_butterfly/services/twitter_service.rb', line 13

def self.track(content, service_options={})
  url = "http://urls.api.twitter.com/1/urls/count.json?url=#{content[:url]}"
  stats = {}
  result = JSON.parse(open(url).read)

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