Class: SeoParams::Facebook
- Inherits:
-
Object
- Object
- SeoParams::Facebook
- Defined in:
- lib/seo_params/facebook.rb
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(url) ⇒ Facebook
constructor
A new instance of Facebook.
- #likes ⇒ Object
Constructor Details
#initialize(url) ⇒ Facebook
Returns a new instance of Facebook.
9 10 11 |
# File 'lib/seo_params/facebook.rb', line 9 def initialize(url) @url = url end |
Instance Method Details
#all ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/seo_params/facebook.rb', line 13 def all api_url = "https://graph.facebook.com/fql?q=select%20click_count,%20comment_count,%20like_count,%20share_count,%20total_count%20from%20link_stat%20where%20url=%22#{@url}%22" # response = ActiveSupport::JSON.decode(open(api_url)) response = JSON.parse(open(api_url).read) h = Hash.new h["click_count"] = response["data"][0]["click_count"] h["comment_count"] = response["data"][0]["comment_count"] h["like_count"] = response["data"][0]["like_count"] h["share_count"] = response["data"][0]["share_count"] h["total_count"] = response["data"][0]["total_count"] h end |
#likes ⇒ Object
26 27 28 29 30 |
# File 'lib/seo_params/facebook.rb', line 26 def likes api_url = "https://graph.facebook.com/fql?q=select%20click_count,%20comment_count,%20like_count,%20share_count,%20total_count%20from%20link_stat%20where%20url=%22#{@url}%22" response =JSON.parse(open(api_url).read) response["data"][0]["like_count"] end |