Sha256: c76d073b32f3f93742ebcee1224355da8e922160b4476b219e9d04512937247a

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

module Twitterland
  module  TweetMeme
    class Analytics
      include HTTParty
      base_uri 'api.tweetmeme.com/analytics'
      format :json
      
      # API Docs: http://help.tweetmeme.com/2009/10/12/analytics-api/
      
      # Sends a request to the Analytics system top build a report for the specified URL. Accessible to anyone with an App ID and App Key.
      #
      #   Twitterland::TweetMeme::Analytics.build(1234, 'OU812', 'http://tweetcongress.org')
      def self.build(app_id, api_key, url)
        Hashie::Mash.new(get("/build.json", :query => {:appid => app_id, :apikey => api_key, :url => url})).uid
      end
      
      # Returns a list of all Analytics that you have built, optionally filtered by domain. Accessible to anyone with an App ID and App Key.
      # 
      #   Twitterland::TweetMeme::Analytics.built(1234, 'OU812', 'http://tweetcongress.org')
      def self.built(app_id, api_key, url=nil)
        options = {:appid => app_id, :apikey => api_key}
        options.merge({:url => url}) unless url.blank?
        Hashie::Mash.new get("/built.json", :query => options)
      end
      
      # Returns the HTML to display the built Analytics to the user. 
      #  Access to this API call is only available to those with elevated permissions to do so. 
      #  In order to get permission, please contact analytics@tweetmeme.com.
      #
      #   Twitterland::TweetMeme::Analytics.get(1234, 'OU812', '37758bd44025edb222022dcd1491c29g')
      def self.get_data(app_id, api_key, uid)
         Hashie::Mash.new get("/get.json", :query => {:appid => app_id, :apikey => api_key, :uid => uid})
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twitterland-0.4.6 lib/twitterland/tweet_meme/analytics.rb