nov / fb_graph

This gem doesn't support FB Graph API v2.0+. Please use fb_graph2 gem instead.
MIT License
1.04k stars 191 forks source link

how notifications work? #391

Closed thiagovsk closed 9 years ago

thiagovsk commented 9 years ago

I was trying to generate a notification using the irb.

I got the ACCESS_TOKEN in Graph Api Explorer

and i got my user with

me = FbGraph::User.me(ACCESS_TOKEN)

and I got my app_access_token with :

app = FbGraph::Application.new(APP_ID, :secret => APP_SECRET)
APP_ACCESS_TOKEN = app.app_access_token.access_token

I tryed

app.notify!(
  me,
  :href => 'http://matake.jp',
  :template => 'Your friend @[12345] achieved new badge!'
)

and

me.notification!(
  :access_token => APP_ACCESS_TOKEN,
  :href => 'http://matake.jp',
  :template => 'Your friend @[12345] achieved new badge!'
)

In both attempts I received

FbGraph::InvalidRequest: OAuthException :: An active access token must be used to query information about the current user.

This is a problem with the graph api explorer? How do I get one acess_token using fb_graph and not the graph API explorer?

Thanks =)

thiagovsk commented 9 years ago

For post, it works , example:

me = FbGraph::User.me(ACCESS_TOKEN)
me.feed!(
  :message => 'Updating via FbGraph',
  :picture => 'https://graph.facebook.com/matake/picture',
  :link => 'https://github.com/nov/fb_graph',
  :name => 'FbGraph',
  :description => 'A Ruby wrapper for Facebook Graph API'
)
thiagovsk commented 9 years ago

@nov it is normal ?

nov commented 9 years ago

sorry for my late response. are you asking whether using APP_ACCESS_TOKEN to access connections under me is normal or not? then the answer is NO. app access token (a.k.a 2-legged token) and user access token (a.k.a 3-legged token) are totally different, and you should use ACCESS_TOKEN when accessing to the user's resource. app access token is for accessing client's own resource.