Sha256: 5fcac481d375256c24448f2737cb4b58bbf2f15320566e4df87a7bad1fc6e66b

Contents?: true

Size: 558 Bytes

Versions: 1

Compression:

Stored size: 558 Bytes

Contents

require 'crack/json'

module ShareChecker
  module Providers
    class Twitter < Provider
      
      # Response sample
      #
      # twttr.receiveCount({"count":38,"url":"http://www.mcdonaldseurokids2012.com.ua/challenges/1/works/98/"})
      #
      def parse(response)
        if response =~ /^twttr.receiveCount\((.+)\)$/i
          obj = Crack::JSON.parse($1)
          obj["count"].to_i  
        end
      end
      
      def url
        "http://urls.api.twitter.com/1/urls/count.json?callback=twttr.receiveCount&url="
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
share_checker-0.1.1 lib/share_checker/providers/twitter.rb