1

I have the following access token:

161551960578281|2.AQDCjxLBWAwdLle6.3600.1311602400.0-544419103231|0L0tcyKgGA0WT3SPJ29CVXqChwk

From this access_token:

App_id = 161551960578281

and

User_id = 544419103231

Can someone provide an example on how to get those programmaticaly using Ruby / RoR.

EDIT:

Do not care if they will change the format in the future!

Immo
  • 601
  • 1
  • 6
  • 19
  • Possible duplicate of [Facebook access token server-side validation for iPhone app](http://stackoverflow.com/questions/5406859/facebook-access-token-server-side-validation-for-iphone-app) – rogerdpack Apr 11 '17 at 20:30

1 Answers1

3

You can't rely on that format being constant, you should use the access token linter at https://developers.facebook.com/tools/access_token/lint which will give you both fields.

Programmatically, you can determine the user ID via a graph API call: https://graph.facebook.com/me?fields=id&access_token=[ACCESS TOKEN HERE] - if the token is still valid you'll get back an answer like this:

{         
"id": "[UID HERE]"
}

I'm not sure of a good way to determine the app ID via an API call, but you should already have this since it's your app.

Igy
  • 43,710
  • 8
  • 89
  • 115
  • I do not care if they will change the access_token format in the future.. Unfortunately I cannot use /me. – Immo Jul 25 '11 at 13:21
  • Well the linter should give you both the user ID and app ID, but if you have a large number of tokens to check there may be a rate limit to stop people spidering that endpoint – Igy Jul 25 '11 at 13:27
  • Yes Linter is what I was looking for. But I want to do it programmatically so my only option at the moment is to split that access token. – Immo Jul 25 '11 at 13:32