JS SDK vs. PHP SDK

佐手、 提交于 2019-12-04 05:20:37

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.

The PHP SDK is exclusively a server-side wrapper around Facebook's APIs.

The JS SDK can be used in the server if you're running Node.js, or in the client.

It's really up to you to decide where you'll be communicating with Facebook from: the client-side or the server-side.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!