简体   繁体   English

Facebook Graph API-结合Javascript SDK和PHP SDK

[英]Facebook Graph API - Combining Javascript SDK and PHP SDK

I'm working on an application that uses FB javascript SDK to login. 我正在使用FB javascript SDK登录的应用程序。 On the server side, I need to do some processing, so I use the following settings: 在服务器端,我需要进行一些处理,因此我使用以下设置:

$config = array(
              'appId' => '45....',
              'secret' => '31.....c1',
              'cookie' => true,
              'fileUpload' => false,
              'allowSignedRequest' => false);

$facebook = new Facebook($config);

So as you see, I re-login to facebook on the server side in order to use the graph API functions otherwise facebook returns an error saying that I need to have an access token to perform this operation. 如您所见,为了使用图形API函数,我重新登录到服务器端的facebook,否则facebook返回错误消息,提示我需要访问令牌才能执行此操作。 I'm wondering if I'm doing the right thing here ... Do i really need to login from the server side too? 我想知道我是否在这里做正确的事...我真的也需要从服务器端登录吗? Or is there a way for the server to know that the user is logged in from the client side (using JS SKD) so I can perform the operations? 还是服务器可以通过某种方式知道用户是从客户端(使用JS SKD)登录的,所以我可以执行操作?

what do you meant login from server side? 从服务器端登录意味着什么?

When you login into an app, either is with js or php, facebook creates an token so user data can be accessed from you app so you could use js login and process data with php or other way around. 当您使用js或php登录应用程序时,facebook会创建一个令牌,以便可以从您的应用程序访问用户数据,因此您可以使用js登录并使用php或其他方式处理数据。

If your login is from somewhere else (eg.: mobile app) you can read the token and send it to server and them work with it, more: https://developers.facebook.com/docs/facebook-login/access-tokens/ 如果您的登录信息来自其他地方(例如:移动应用程序),则可以读取令牌并将其发送到服务器,然后他们可以使用该令牌,详情请参见https//developers.facebook.com/docs/facebook-login/access-令牌/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM