Sha256: e0d56f5f7e1ab6c0dd874d7f424bd6f24a9b1454fa5c6245584925930c6799ee

Contents?: true

Size: 1.88 KB

Versions: 37

Compression:

Stored size: 1.88 KB

Contents

module FbGraph
  module Connections
    module Subscriptions
      # == Fetch current subscriptions
      # 
      #   app = FbGraph::Application.new(APP_ID, :secret => APP_SECRET)
      #   app.subscriptions
      #   => Array of FbGraph::Subscriptions
      def subscriptions(options = {})
        options[:access_token] ||= self.access_token
        subscriptions = self.connection(:subscriptions, options)
        subscriptions.map! do |subscription|
          Subscription.new(subscription.merge(:access_token => options[:access_token]))
        end
      end

      # == Subscribe
      # 
      # Subscriber have to setup PubSubHubbub subscriber endpoint.
      # See details at "Subscription Verification" in the Facebook API document.
      # ref) http://developers.facebook.com/docs/api/realtime
      # 
      #   app = FbGraph::Application.new(APP_ID, :secret => APP_SECRET)
      #   app.subscribe!(
      #     :object => "user",
      #     :fields => "name,email",
      #     :callback_url => "http://fbgraphsample.heroku.com/subscription",
      #     :verify_token => "Define by yourself"
      #   )
      #   => Array of FbGraph::Subscriptions
      def subscribe!(options = {})
        options[:access_token] ||= self.access_token
        post(options.merge(:connection => :subscriptions))
      end

      # == Subscribe
      # 
      # Delete all of your subscriptions.
      # If you specify an object parameter, it will only delete the corresponding subscription.
      # ref) http://developers.facebook.com/docs/api/realtime
      # 
      #   app = FbGraph::Application.new(APP_ID, :secret => APP_SECRET)
      #   app.unsubscribe!(
      #     :object => "user"
      #   )
      #   => Array of FbGraph::Subscriptions
      def unsubscribe!(options = {})
        options[:access_token] ||= self.access_token
        destroy(options.merge(:connection => :subscriptions))
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
fb_graph-2.1.3 lib/fb_graph/connections/subscriptions.rb
fb_graph-2.1.2 lib/fb_graph/connections/subscriptions.rb
fb_graph-2.1.1 lib/fb_graph/connections/subscriptions.rb
fb_graph-2.1.0 lib/fb_graph/connections/subscriptions.rb
fb_graph-2.1.0.alpha lib/fb_graph/connections/subscriptions.rb
fb_graph-2.0.2 lib/fb_graph/connections/subscriptions.rb
fb_graph-2.0.1 lib/fb_graph/connections/subscriptions.rb
fb_graph-2.0.0 lib/fb_graph/connections/subscriptions.rb
fb_graph-2.0.0.beta lib/fb_graph/connections/subscriptions.rb
fb_graph-2.0.0.alpha lib/fb_graph/connections/subscriptions.rb
fb_graph-1.9.5 lib/fb_graph/connections/subscriptions.rb
fb_graph-1.9.4 lib/fb_graph/connections/subscriptions.rb
fb_graph-1.9.3 lib/fb_graph/connections/subscriptions.rb
fb_graph-1.9.2 lib/fb_graph/connections/subscriptions.rb
fb_graph-1.9.1 lib/fb_graph/connections/subscriptions.rb
fb_graph-1.9.0 lib/fb_graph/connections/subscriptions.rb
fb_graph-1.8.6 lib/fb_graph/connections/subscriptions.rb