Class: ShareChecker::Providers::Twitter

Inherits:
ShareChecker::Provider show all
Defined in:
lib/share_checker/providers/twitter.rb

Instance Attribute Summary

Attributes inherited from ShareChecker::Provider

#name

Instance Method Summary collapse

Methods inherited from ShareChecker::Provider

#check, get, #initialize, #method_missing, #parse_json, #parse_xml

Constructor Details

This class inherits a constructor from ShareChecker::Provider

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ShareChecker::Provider

Instance Method Details

#parse(response) ⇒ Object

Response sample

twttr.receiveCount(href="http://www.mcdonaldseurokids2012.com.ua/challenges/1/works/98">www.mcdonaldseurokids2012.com.ua/challenges/1/works/98/”)



9
10
11
12
13
14
# File 'lib/share_checker/providers/twitter.rb', line 9

def parse(response)
  if response =~ /^twttr.receiveCount\((.+)\)$/i
    doc = parse_json($1)
    doc.nil? ? 0 : doc["count"].to_i
  end
end

#urlObject



16
17
18
# File 'lib/share_checker/providers/twitter.rb', line 16

def url
  "http://urls.api.twitter.com/1/urls/count.json?callback=twttr.receiveCount&url="
end