JS SDK与PHP SDK [英] JS SDK vs. PHP SDK

查看:132
本文介绍了JS SDK与PHP SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我对各种网站的简短的探索,似乎JS SDK比PHP SDK更常用。即使在PHP中实现的网站也使用JS SDK。 PHP参考页有776个喜欢,而JS参考页有20k +喜欢。 PHP参考页面说,PHP SDK可以帮助您将Facebook登录添加到您的页面,但即使Login Button也使用JS SDK。 PHP SDK实际上是否具有任何优势?为什么在PHP SDK中投入很少的努力?

解决方案

那么JS SDK一定会更受欢迎。不是每个人都在PHP中开发服务器端代码(可能使用Java / Scala / .NET / Python / etc等),但是每个人都不得不在JavaScript中编写客户端代码。对于两者的好处,可以使用JavaScript SDK确实有好处。




  • 服务器上的负载较少

  • 请求直接从客户端浏览器访问Facebook,而不是从浏览器=>您的服务器=> Facebook,然后再次返回,更好的响应时间。



当然,您必须在服务器端执行操作,无论是因为要将结果存储在数据库中,还是其安全敏感操作。 (例如,您永远不会将您的应用访问权限传递给客户端,并将其从那里使用,作为其秘密)。



此外,PHP SDK中还加入了很少的努力,因为它非常简单,它的所有标准HTTP东西就像做出GET请求并返回Json / XML响应,从POST参数读取signed_request并进行解码。没有任何SDK可以很容易地完成。 (这是开发人员使用其他服务器端语言的)。对于必须处理跨浏览器问题的JavaScript SDK,不能说同样的事情,必须与FB进行通信,以便滚动画布页面或弹出Iframe对话框。如果没有一个很好的测试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?

解决方案

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.

这篇关于JS SDK与PHP SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆