1

I'm just starting to create a in-facebook app. I'm bugging at the first step, when a user access my app for the first time. Basically, I want a welcome page to explain what is that app before requesting an access to information. A cute image with cats, whatever, but not sending directly the user to the login to my app dialog.

So, user didn't sign in to my app, I only have the "app access token" to work with the graph. According to this official Facebook dev page (at the end), I'm supposed to have some basic information access.

Question is : how ? What are the calls that I can make to the graph with an app access token ?

/me is a no go, it requires a user access token.

/$user_id is public information, with or without a token, I can retrieve basic info. But I don't have any user_id to use through the $signedRequest (which gives only country,locale & age)

How am I to get (quote):

- Basic Profile Info of a User (ID, Name, Username, Gender)
- A User’s Friends and their IDs
- Permissions granted by the User to your App
DColl
  • 175
  • 2
  • 14

2 Answers2

4

You shouldn't be using your application token for anything other than administration of your app.

It's not possible to get data before a user actually grants it.

The paragraph you mentioned is within the limits of your application

While an App Access Token is largely for the purposes of publishing information back to Facebook on behalf of the user, there is a limited set of information that can be retrieved from Facebook using an App Access Token.

  • Basic Profile Info of a User (ID, Name, Username, Gender)
  • A User’s Friends and their IDs
  • Permissions granted by the User to your App

Say I know User001 added my app, and I want to check on some items for administration. I don't have User001's access token (or rather I shouldn't be manually using it) So instead I supply the application access token to get data that would normally return

Friends

Notice I can supply an app token allowing me to see friends (of the user who added the app) but if I choose an object not mentioned in those bullet points...

No access

phwd
  • 19,949
  • 5
  • 47
  • 77
  • ok, thanks for the rapid comeback. I think i'm starting to understand things the "facebook" way.. Your first statement is what's important : APP access token is ONLY for administrative purposes, ONCE a user as already granted you access. Tell me if i'm correct on that, I belive the documentation should be more explicit on this usage. /me walk around looking for a different approach now – DColl Apr 30 '13 at 11:19
  • correct, /me is basically a shortcut for the current user/page that has been given an access token. If you have a user access token, me will return the authenticated user, if you have a page access token me will return the authenticated page. – phwd Apr 30 '13 at 17:03
0
  • Basic Profile Info of a User (ID, Name, Username, Gender):

Yes. https://graph.facebook.com/USER_ID?fields=id,name,%20username,%20gender&access_token=APP_ACCESS_TOKEN

  • A User’s Friends and their IDs

If you request https://graph.facebook.com/USER_ID/friends?access_token=APP_ACCESS_TOKEN, you would get:

{ "error": { "message": "Can't lookup all friends of 100001234567. Can only lookup for the logged in user or the logged in user's friends that are users of your app.", "type": "NoIndexFunctionException", "code": 604 } }

The answer for legal solution is, NO, you must use user access token. Similar disscussion here Get the Friends of my friend using the Graph API

Permissions granted by the User to your App

Yes. https://graph.facebook.com/USER_ID/permissions?access_token=APP_ACCESS_TOKEN

Community
  • 1
  • 1
Fruit
  • 6,309
  • 3
  • 42
  • 57
  • But in the first place, I would need the USER_ID, which I can't retrieve without a specific grant access from the user. Along with that, token or not, you can get basic info from a user_id. The hard part is to first know with whom your app is talking to, which Facebook didn't make as easy as I would though... thanks for the comeback – DColl Apr 30 '13 at 11:25
  • Or you're able to access the user's cookies? The user id is inside cookies file, example: .facebook.com TRUE / TRUE 0 c_user 12012345 – Fruit Apr 30 '13 at 11:37
  • i'm not a web developer, however, what i know is the cookie have the user id(If the user is loggedin). I'm not sure you able to retrieve the cookie or not, i just provide the possibility. :) – Fruit Apr 30 '13 at 12:22