简体   繁体   中英

Facebook Graph API - Combining Javascript SDK and PHP SDK

I'm working on an application that uses FB javascript SDK to login. 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. 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?

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.

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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