Query test users through Facebook Graph API
I am creating an application with Facebook Connect. I have created a test user using techniques from http://developers.facebook.com/blog/post/429.
I can log in to Facebook as the ne开发者_高级运维wly created user, but can't access even basic information for the user through the Facebook Graph API. With real users, I can use URLs like http://graph.facebook.com/. This isn't working with my test user.
I have tried the same URL using CURL with and without an application access token with both http and https.
Does anyone know if Facebook test users are queryable through the graph API and if so how?
You need to use the user's access token (or maybe the access token of any of the app's users). You should be able to query the access token of the user by using the Graph API (just GET /app_id/accounts/test-users). This will get you the id and the token. Then, make a second call to the API using the token you got (https://graph.facebook.com/id?access_token=...)
So, if your user id was 10017, and your access token was ABC, the call would be https://graph.facebook.com/10017?access_token=ABC.
Thanks for the help Matt. I finally sent a message to the software engineer at Facebook that wrote the article I linked to in my question and he gave me the answer.
You can query a test user only with the access token of another test user.
I don't know how useful that is if the app uses the graph API. It means the app access token isn't sufficient to query test users. I may not like it but it appears that's the answer.
One of the comments in the post: "You can see a test account's wall by logging in either as that test account or as a friend of that test account (only test accounts can friend test accounts). Use login_url property for logging in."
So I suggest logging in as the user and adding information like you would a regular profile and then try accessing it. I don't believe it gives you "dummy data" by default other than your login info.
Also: look at the doc for test users. It's got information on the limitations and how to access the user accounts.
UPDATE: AFAIK the test user api doesn't currentlly allow queries with the graph api for information other than a login token.
精彩评论