Facebook Connect Graph API - 为什么我无法检索所有用户的详细信息?
我觉得我在这里问的每一个问题都与 Facebook Connect 有关——这说明了很多关于他们的 API 的信息。无论如何,这就是政治,我离题了。
我试图从 Graph API 中提取用户详细信息以在我的应用程序中使用(这是一个 FBML 外部网站 - 用于身份验证的 JavaScript SDK)。
我已向用户请求以下权限:(使用常规对话框)
- publish_stream
这有效,允许我发布到用户的留言墙上,并从 Graph API 获取他们的电子邮件。
但是当我对以下 URL 执行 HTTP GET 请求时:
https://graph. facebook.com/uid?access_token=oat (其中 uid = 我试图获取其详细信息的用户的用户 ID,oat = 我拥有的 OAuth 令牌)。
JSON 中返回的只是用户 ID(我已经有了,因为我将其放入 URL 中)和电子邮件。
为什么我无法获取名字、姓氏、区域设置等信息?
我使用了错误的网址吗?我的 OAuth 令牌是否错误?
我从这里获取 OAuth 令牌:
更新:
看起来问题是我的OAuth 令牌。
因为当我去文档时: http://developers.facebook.com/docs/api
并为尝试检索的用户使用示例 OAuth 令牌,它会获取所有详细信息。
有人知道我的 OAuth 令牌调用有什么问题吗?
I feel like every second question i ask here is relating to Facebook Connect - that says a lot about their API. Anyway, that's politics, i digress..
I'm trying to pull back user details from the Graph API for use in my application (which is an FBML external website - JavaScript SDK for authentication).
I have requested the following permissions from the user: (using the regular dialog)
- publish_stream
This works, and allows me to post to the user's wall, and grab their email from the Graph API.
But when i do a HTTP GET Request to the following URL:
https://graph.facebook.com/uid?access_token=oat (where uid = the user id of the user i'm attempting to grab details for, and oat = the OAuth token i have).
All that comes back in the JSON is the User ID (which i already have, since im putting it in the URL), and the email.
Why can i not get things like first name, last name, locale, etc?
Am i using the wrong URL? Is my OAuth token wrong?
I'm getting the OAuth token from here:
UPDATE:
It looks like the issue is my OAuth token.
Because when i go to the docs: http://developers.facebook.com/docs/api
And use the sample OAuth Token for the user im trying to retrieve, it gets all the details.
Anyone know what is wrong with my OAuth token call?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,我使用了错误的 OAuth Exchange URL。它需要是这样的:
https://graph .facebook.com/oauth/exchange_sessions?type=client_cred&client_id=myappid&client_secrete=myappsecret&sessions=userseshid
我使用的 URL 是按照 doco 的,上面的有效方法是无处可寻。
我对 FBC 的态度是,我不再关心如何,如果它有效,请庆幸它甚至做到了这一点,然后继续前进。
编辑:
另外,我想知道为什么 Graph API 调用会无缘无故“停止”工作。
答案是我需要将用于获取 OAuth 令牌的会话密钥与当前在 cookie 中的会话密钥进行比较。如果它们不同,我需要获取新的 OAuth 令牌。
用于任何 OAuth 令牌的会话密钥都是实际 OAuth 令牌的一部分:
其中 bbbb 是会话密钥。所以我只是在进行任何 Graph API 调用之前进行比较。
So, i was using the wrong URL for the OAuth Exchange. It needed to be this:
https://graph.facebook.com/oauth/exchange_sessions?type=client_cred&client_id=myappid&client_secrete=myappsecret&sessions=userseshid
The URL that i WAS using was as per the doco, the above one that works is nowhere to be found.
I'm at the point with FBC that i no longer care about the how, if it works, be thankful that it does even that and move on.
EDIT:
Also, i was wondering why the Graph API calls would "stop" working for no reason.
The answer is i needed to compare the Session Key used to obtain the OAuth token, with the Session Key currently in the cookies. If they are different, i needed to get a new OAuth token.
The session key used for any OAuth token is part of the actual OAuth token:
Where bbbb is the session key. So i just compare that before doing any Graph API calls.