FQL 查询和 Graph API 对象访问之间的区别
使用 Facebook Graph API 访问用户数据 (http://graph.facebook.com/btaylor)并使用 Graph API 对同一用户进行 FQL 查询 ( https://api.facebook.com/method/fql.query?query=QUERY)。
另外,有谁知道 Facebook 开发工具包(用于 ASP.NET)使用其中的哪一个?
我之所以问这个问题,是因为我试图在登录用户在我的网站上开始 Facebook Connect 会话后访问他们的生日,但当我使用该工具包时,它不会返回该信息。但是,如果我手动调用该用户对象的 Graph API,它会返回该对象。我从工具包中进行的调用可能有问题。我想我可能需要包含会话密钥,但我不确定如何获取它。这是我正在使用的代码:
_connectSession = new ConnectSession(APPLICATION_KEY, SECRET_KEY);
try
{
if (!_connectSession.IsConnected())
{
// Not authenticated, proceed as usual.
statusResponse = "Please sign-in with Facebook.";
}
else
{
// Authenticated, create API instance
_facebookAPI = new Api(_connectSession);
// Load user
user user = _facebookAPI.Users.GetInfo();
statusResponse = user.ToString();
ViewData["fb_user"] = user;
}
}
catch (Exception ex)
{
//An error happened, so disconnect session
_connectSession.Logout();
statusResponse = "Please sign-in with Facebook.";
}
What's the difference between accessing user data with the Facebook Graph API (http://graph.facebook.com/btaylor) and using the Graph API to make a FQL query of the same user (https://api.facebook.com/method/fql.query?query=QUERY).
Also, does anyone know which of them the Facebook Developer Toolkit (for ASP.NET) uses?
The reason I ask is because I'm trying to access the logged in user's birthday after they begin a Facebook Connect session on my site, but when I use the toolkit it doesn't return it. However, if I make a manual call to the Graph API for that user object, it does return it. It's possible I might have something wrong with my call from the toolkit. I think I may need to include the session key, but I'm not sure how to get it. Here's the code I'm using:
_connectSession = new ConnectSession(APPLICATION_KEY, SECRET_KEY);
try
{
if (!_connectSession.IsConnected())
{
// Not authenticated, proceed as usual.
statusResponse = "Please sign-in with Facebook.";
}
else
{
// Authenticated, create API instance
_facebookAPI = new Api(_connectSession);
// Load user
user user = _facebookAPI.Users.GetInfo();
statusResponse = user.ToString();
ViewData["fb_user"] = user;
}
}
catch (Exception ex)
{
//An error happened, so disconnect session
_connectSession.Logout();
statusResponse = "Please sign-in with Facebook.";
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Graph API 和 FQL 的相似之处在于它们都访问相同的底层 Facebook 对象:统称为“社交图”的节点。 Graph API 是一种简单、统一且相当直接的访问这些对象的方法。如果您确切地知道自己在寻找什么,那么 Graph API 是获取它的简单方法。
另一方面,FQL 是一种查询语言(如 SQL)。它允许您搜索使用简单、直接的图形 API 不可能(或复杂)找到的图形对象。
FQL 相对于 Graph API 的另一项重要功能是能够将多个查询批处理为一次调用(这可以为您节省多部分查询的往返时间)。
最终,Graph API 似乎更直接地表示了社交图中“幕后”发生的事情,因此我发现它在可能的情况下使用起来更简单。但是,如果我的 Graph API 请求变得非常长或难以理解(或者任何时候我需要对社交图进行多个相关查询),则表明是时候切换到 FQL 了。
The Graph API and FQL are similar in that they both access the same underlying Facebook objects: the nodes that are collectively referred to as "the social graph". The Graph API is a simple, uniform, and fairly direct way to access these objects. If you know exactly what you're looking for, the Graph API is a simple way to get it.
FQL, on the other hand, is a query language (like SQL). It allows you to search for graph objects that would be impossible (or complicated) to find using the simple, direct Graph API.
Another big feature FQL has over the Graph API is the ability to batch multiple queries into a single call (which can save you a lot of time in roundtrips for multipart queries).
Ultimately, the Graph API seems a more direct representation of what's going on "under the covers" in the social graph, so I find it simpler to use when I can. But if my Graph API request is getting really long or incomprehensible (or any time I need to make more than one related query of the social graph), that's the sign that it's time to switch over to FQL.
我无法获得生日和我正在寻找的其他信息的原因似乎是因为我没有可以请求的所有扩展权限的完整列表。我终于在 http://developers.facebook.com/docs/authentication/permissions< 找到了该列表/a> (其中包括 user_birthday)。
如果有人有关于 FQL 与图形对象问题的信息,我仍然对此感兴趣。虽然我认为它们基本上是同一件事。
It seems the reason I couldn't get the birthday and other information I was looking for was because I didn't have a complete list of all the extended permissions that could be requested. I finally found the list at http://developers.facebook.com/docs/authentication/permissions (which included user_birthday).
If anyone has info about the FQL vs. Graph Object question, I'd still be interested in that. Though I think they are basically the same thing.
看起来这已经改变了(是的,又是)。因为您使用的是 facebook connect,所以您可以请求权限来为您提供所需的信息,例如用户的生日,如下所示:
更多信息:
http://developers.facebook.com/docs/guides/web#login
Looks like that have changed it (yes yet again). Because you are using facebook connect, you can ask for the permissions to give you the needed info for example user's birthday something like:
More Information:
http://developers.facebook.com/docs/guides/web#login