views:

63

answers:

2

Why would I want to use Facebook's JS SDK for making API calls....meaning use the FB.api() method when I can simply send the HttpRequest and get back the JSON very easily using the jQuery getJSON for any api calls.

I think of the benefits of using the FB.api is that it already already grabs and knows about the user's token from the cookie right? But then the not so nice part is finding a way to parse through the returned JSON data if not using the getJSON method. I can't think of any benefits here outside of this unless there are methods I can act on such as FB.api().SomeMethod.

I see at this point using the JS SDK for authing and maintaining the user's info in a cookie which is is great, but if I can simply use jQuery like I have with any other API returning JSON for api calls thereafter, is there anything from stopping me with Facebook? Any show stoppers?

What are you using out there?

+1  A: 

Definitely use FB.api - like you mention their SDK handles all the token/session stuff for you.

And if you're concerned about parsing the JSON in the result handler, don't. Just use jQuery's parseJSON.

Peter Bailey
thanks I just couldn't find that jquery method. That works exactly how I want it...best of both worlds (the fb JS API method and jQuery) together.
CoffeeAddict
A: 

It's absolutely okay to use whichever works for you :) One of the huge advantages since we introduced support for OAuth2 is that an authenticated request simply involves an additional query parameter. If you crack open FB.api(), you'll see it's using JSONP mostly like jQuery.

daaku
so you mean it's sending back JSON objects? Either way I need to parse out the objects right? I just tried the getJSON and works great when I grab the response of the FB.api() method's callback
CoffeeAddict
I will be using the JS SDK for authing at the least, it saves me from a lot of overhead on the session. But as far as using the rest of the methods in that SDK, I just don't see why....wanted to see other's experiences in that maybe there are other benefits here.
CoffeeAddict
Yes, it's sending back JSON (in fact, the new Graph API supports nothing but JSON). We wanted to provide API support that did not require jQuery :)
daaku