Sha256: e94ac41f71f352fe2ad8b571c9914564a88bc4f591ea216d8f05d6fd8b0672fb

Contents?: true

Size: 564 Bytes

Versions: 5

Compression:

Stored size: 564 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
          doc = parse_json($1)
          doc.nil? ? 0 : doc["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

5 entries across 5 versions & 1 rubygems

Version Path
share_checker-0.1.6 lib/share_checker/providers/twitter.rb
share_checker-0.1.5 lib/share_checker/providers/twitter.rb
share_checker-0.1.4 lib/share_checker/providers/twitter.rb
share_checker-0.1.3 lib/share_checker/providers/twitter.rb
share_checker-0.1.2 lib/share_checker/providers/twitter.rb