Mau Ruiz
Mau Ruiz

Reputation: 777

User Data from Facebook WITHOUT SDK

I have the access token from the user, and I want to retrive the data from their profile. I am working on Unity3D c# therefore I can not use any SDK. Is there a way of getting it trough a graph request?

I've already tried with

https://graph.facebook.com/me?access_token=00000000000000|AAAAAAAAAAAAAAA

but throws me an error like this..

  "message": "An active access token must be used to query information about the current user.",

When I ask for permissions I ask the user to allow me the publish_stream and to access profile data. How do I get an active access token? I just want the UserID.

Thanks for your answers, and sorry for my terrible english.

Upvotes: 3

Views: 183

Answers (3)

Mau Ruiz
Mau Ruiz

Reputation: 777

So I wanted ti get the User UserAgent Token the only thing that you must do is add that parameter to the Access URL in my case

https://graph.facebook.com/oauth/authorize?type=user_agent&client_id=000000000000000&redirect_uri=http://yourRedirectdomain.com&scope=user_photos,email,user_birthday,offline_access,plublish_stream

Facebook will redirect you to the redirect_uri URL, and the access token will be given in form of a hash. Extra Tip: Yo have to access the Hashed token vía Javascript,

var hash = document.location.hash;
 var n=hash.split("=");

This is one method, Im sure there is a better one.

Thank everybody for the answers!

Upvotes: 2

C3roe
C3roe

Reputation: 96226

You can’t query the API for /me with an app access token, since the API has no way of knowing who “me” is supposed to be.

Only user access tokens contain the info which user id they apply to, and hence only those can be used to query /me successfully.

Upvotes: 0

Owen Berry
Owen Berry

Reputation: 401

you're Graph Call / HTTP request looks about right.

I'm guessing, based on the error, that the access token has expired. Normally, they last for about 1-2 hours since the last time they were used. (If i recall correctly). So, a user will start using a website, and the website can make graph calls with the access token while the user is actually using the website for that session, but the token will expire soon after that.

However, you can also ask Facebook for a longer lasting access_token, which will last for approximately 60 days. Check here for some info :: http://developers.facebook.com/roadmap/offline-access-removal/

As it stands, trying to find this info through browsing the developer docs in Facebook is rather difficult, if not impossible. :-/

Upvotes: 0

Related Questions