Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JS SDK vs. PHP SDK

From my brief exploration around various websites, it seems that the JS SDK is much more commonly used than the PHP SDK. Even sites that are implemented in PHP use the JS SDK. The PHP reference page has 776 likes, whereas the JS reference page has 20k+ likes. The PHP reference page says the PHP SDK helps you add Facebook Login to your page, but even the Login Button uses the JS SDK. Does the PHP SDK actually have any advantage at all? Why so little effort is being put into the PHP SDK?

like image 516
Kar Avatar asked Jan 19 '12 12:01

Kar


1 Answers

Well, the JS SDK is bound to be more popular. Not everyone develops their server side code in PHP, (could be using Java/Scala/.NET/Python/etc etc) but everyone does have to write their client-side code in JavaScript.

As to the benefits of either, there are certainly benefits to using the JavaScript SDK when you can.

  • Less load on your server.
  • Better response time as the request goes straight from the clients browser to Facebook, rather than from their browser => your server => Facebook, and back again.

There is of course times when you have to do things server side, either because you want to store the result in your database, or its a security sensitive operation. (for example you would never pass your app access_token down to the client and use it from there, as its secret).

Also 'so little effort' is put into the PHP SDK because its really quite simple, its all standard HTTP stuff like making a GET request and getting back a Json/XML response, reading the signed_request from the POST parameters and decoding it. It can be done without any SDK very easily. (And this is what developers using other server-side languages do). The same cannot be said for the JavaScript SDK, which has to deal with cross-browser issues, has to communicate with FB to do things like scroll your canvas page or popup an Iframe dialog. You would have to be a little crazy to attempt to do it without a well test SDK.

like image 69
aidanok Avatar answered Sep 28 '22 09:09

aidanok