Module: FbGraph::Connections::Subscriptions
- Included in:
- Application
- Defined in:
- lib/fb_graph/connections/subscriptions.rb
Instance Method Summary collapse
-
#subscribe!(options = {}) ⇒ Object
Subscribe.
-
#subscriptions(options = {}) ⇒ Object
Fetch current subscriptions.
-
#unsubscribe!(options = {}) ⇒ Object
Subscribe.
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.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
31 32 33 34 |
# File 'lib/fb_graph/connections/subscriptions.rb', line 31 def subscribe!( = {}) [:access_token] ||= self.access_token || get_access_token([:secret]) post(.merge(:connection => :subscriptions)) end |
#subscriptions(options = {}) ⇒ Object
Fetch current subscriptions
app = FbGraph::Application.new(APP_ID, :secret => APP_SECRET)
app.subscriptions
=> Array of FbGraph::Subscriptions
9 10 11 12 13 14 15 |
# File 'lib/fb_graph/connections/subscriptions.rb', line 9 def subscriptions( = {}) [:access_token] ||= self.access_token || get_access_token([:secret]) subscriptions = self.connection(:subscriptions, ) subscriptions.map! do |subscription| Subscription.new(subscription.merge(:access_token => [: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.facebook.com/docs/api/realtime
app = FbGraph::Application.new(APP_ID, :secret => APP_SECRET)
app.unsubscribe!(
:object => "user"
)
=> Array of FbGraph::Subscriptions
47 48 49 50 |
# File 'lib/fb_graph/connections/subscriptions.rb', line 47 def unsubscribe!( = {}) [:access_token] ||= self.access_token || get_access_token([:secret]) destroy(.merge(:connection => :subscriptions)) end |