通过Facebook Graph API查询测试用户
我正在使用 Facebook Connect 创建一个应用程序。我使用 http://developers.facebook.com/blog/post/ 中的技术创建了一个测试用户429。
我可以作为新创建的用户登录 Facebook,但无法通过 Facebook Graph API 访问用户的基本信息。对于真实用户,我可以使用 http://graph.facebook.com/ 这样的 URL。这不适用于我的测试用户。
我已经尝试使用带有和不带有 http 和 https 的应用程序访问令牌的 CURL 来访问相同的 URL。
有谁知道 Facebook 测试用户是否可以通过图形 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 newly 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要使用用户的访问令牌(或者可能是任何应用程序用户的访问令牌)。您应该能够使用 Graph API 查询用户的访问令牌(只需 GET /app_id/accounts/test-users)。这将为您提供 id 和令牌。然后,使用您获得的令牌对 API 进行第二次调用 (https://graph.facebook.com/id?access_token=...)
因此,如果您的用户 ID 为 10017,并且您的访问令牌为 ABC,则调用将是 https://graph.facebook.com/10017?access_token=ABC。
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.
感谢马特的帮助。我最终给 Facebook 的软件工程师发了一条消息,他写了我在问题中链接到的文章,他给了我答案。
我不知道如果应用程序使用图形 API,这会有多大用处。这意味着应用程序访问令牌不足以查询测试用户。我可能不喜欢它,但这似乎就是答案。
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.
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.
帖子中的评论之一:
“您可以通过以测试帐户或该测试帐户的好友身份登录来查看测试帐户的墙(只有测试帐户可以与测试帐户成为好友)。使用 login_url 属性进行登录。”
因此,我建议以用户身份登录并添加信息,就像添加常规个人资料一样,然后尝试访问它。我不相信除了您的登录信息之外,默认情况下它不会为您提供“虚拟数据”。
另外:查看测试用户文档。它提供了有关限制以及如何访问用户帐户的信息。
更新:据我所知,测试用户 api 目前不允许使用图形 api 查询登录令牌以外的信息。
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.