To test JS-session on the server?

A simple question, but Google failed.


Is a function of the JS Api: FB.login(callback...);

Callback receives the old types:
response = {<br>
authResponse = {<br>
accessToken = "...mnogoboryu..."<br>
expiresIn = 4734,<br>
signedRequest = "...mnogoboryu..."<br>
userID = "100001415486037"<br>
}, <br>
status = "connected"<br>
}


Who knows where to dig, so these data it was possible to check in PHP? At VK it was tricky, but easy to understand the hash (md5). There is such no hint.
October 8th 19 at 00:13
1 answer
October 8th 19 at 00:15
Solution
Have your php Facebook API
Working with him like this:

require_once 'facebook.php';
$facebook = new Facebook(array(/* here the configs for FB */));
$user = $facebook->getUser();

if ($user) {
 try {
 $userProfile = $facebook->api('/me');
 // ... something else
 } catch (FacebookApiException $e) {
 // somehow handle the error from FB
}
}
FB PHP API - Eve_Cartwright commented on October 8th 19 at 00:18
About PHP Api I read, like, there is a separate authorization method. I need to check the session obtained in the JS Api. - rebeca_Sta commented on October 8th 19 at 00:21
The issue has been resolved. Interested in give code (the AJAX script passed ID and Token):
include(BASEPATH.'inc/facebook.php');
$fb = new Facebook(array('appId'=>'432274376798188','secret'=>'...'));
$fb->setAccessToken($params['fb_token']);
$user = $fb->getUser();
if($user && ($user == $params['fb_id'])){
...
}
- rebeca_Sta commented on October 8th 19 at 00:24
You complicate.
Read the link that I gave above:
Used in conjunction with the JavaScript SDK, the PHP SDK can share user sessions seamlessly across the client and server. If a user is already logged in to their Facebook account, the JavaScript SDK will pick up the login session and send it to the server via a cookie, which the PHP SDK reads without any intervention on the developer's part
- Eve_Cartwright commented on October 8th 19 at 00:27
Not at all. If you do not specify token manually, consistently getUser returns zero. - rebeca_Sta commented on October 8th 19 at 00:30

Find more questions by tags FacebookSessionsPHPJavaScript