开发者

Help understanding how to integrate the FB Graph API in my App

开发者 https://www.devze.com 2023-03-02 09:23 出处:网络
I\'m working to enable my app to hit the FB Graph API to look up data on a user. I want to do this in a way that is app focused meaning it isn\'t based on a user signed into my app. It\'s a relationsh

I'm working to enable my app to hit the FB Graph API to look up data on a user. I want to do this in a way that is app focused meaning it isn't based on a user signed into my app. It's a relationship between the app & the FB Graph API.

My understanding is I can do that with the APPLICATION ACCESS TOKEN is that right?

If I use my app acce开发者_如何学Pythonss token here: https://graph.facebook.com/search?q=born@gmail.com&type=user&access_token=208131059208382|xFN8da1tIDxuuMp8hoRtGs3l0aM

I get an error:

{
   "error": {
      "type": "OAuthException",
      "message": "An access token is required to request this resource."
   }
}

Why is that?

Can I use my personal FB account to hit the API for the purposes of the app?

When a user oAuth's in to an app, how long does the access token last? Is it something I can hard code in my app so I can hit the FB graph api?

Thanks


For a lot of things on Facebook, you have to have a valid session access token from the user. What this means is, the access token you get from a user must be used to access a resource. This is especially true when pulling data about the user out of the graph. The access token that FB gives you when the user loads your application typically lasts for an hour (if I recall correctly). The session object FB gives you tells you the expire time on the token, though.

If you need to access the data for a user in an offline manner, you could ask the user for the offline_access extended permission. Doing this makes Facebook give you an indefinite access token, which doesn't ever expire (unless the user changes their password). That allows you to query the graph on the user's behalf whenever you feel like doing it.

The search feature doesn't require an access token if you're performing a standard search, or a page search, etc. But it does require a valid access token when you're searching for users. I assume this is to keep people from hammering the search and crawling public user data with a bot.


You can follow the instruction in

http://developers.facebook.com/docs/authentication/


take a look at https://github.com/michaelbaldry/fb_graph_canvas - It's a barebones canvas application that you can test locally. It uses fb_graph and is about as simple as can.

0

精彩评论

暂无评论...
验证码 换一张
取 消