Module: GSGraph::Connections::Subscriptions

Included in:
Application
Defined in:
lib/gs_graph/connections/subscriptions.rb

Instance Method Summary collapse

Instance Method Details

#subscribe!(options = {}) ⇒ Object

Subscribe

Subscriber have to setup PubSubHubbub subscriber endpoint. See details at “Subscription Verification” in the Facebook API document. ref) developers.gamestamper.com/docs/api/realtime

app = GSGraph::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 GSGraph::Subscriptions


31
32
33
34
# File 'lib/gs_graph/connections/subscriptions.rb', line 31

def subscribe!(options = {})
  options[:access_token] ||= self.access_token
  post options.merge(:connection => :subscriptions)
end

#subscriptions(options = {}) ⇒ Object

Fetch current subscriptions

app = GSGraph::Application.new(APP_ID, :secret => APP_SECRET)
app.subscriptions
=> Array of GSGraph::Subscriptions


9
10
11
12
13
14
15
# File 'lib/gs_graph/connections/subscriptions.rb', line 9

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

#unsubscribe!(options = {}) ⇒ Object

Subscribe

Delete all of your subscriptions. If you specify an object parameter, it will only delete the corresponding subscription. ref) developers.gamestamper.com/docs/api/realtime

app = GSGraph::Application.new(APP_ID, :secret => APP_SECRET)
app.unsubscribe!(
  :object => "user"
)
=> Array of GSGraph::Subscriptions


47
48
49
50
# File 'lib/gs_graph/connections/subscriptions.rb', line 47

def unsubscribe!(options = {})
  options[:access_token] ||= self.access_token
  destroy options.merge(:connection => :subscriptions)
end