Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Diffence between FQL query and Graph API object access

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.";
        }
like image 409
jwynveen Avatar asked Feb 28 '23 02:02

jwynveen


1 Answers

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.

like image 123
jemmons Avatar answered Mar 01 '23 22:03

jemmons