开发者

Facebook's JS SDK vs. just using jQuery's getJSON for API calls

开发者 https://www.devze.com 2023-01-08 03:37 出处:网络
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

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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号