Are you sure you set the the "FBRLH_state" key in $_SESSION? You can use Session::put in Laravel to do this, and Session::get to retrieve the data (that way it won't die on an undefined index error). If you're already doing this somewhere else, check if there's anything even in $_SESSION["FBRLH_state"].
@s1dd, I didn't set anything. I believe facebook has set the session. I am just trying to get an access_token to get the user's profile. Thank you.
According to Facebook's documentation for the PHP SDK: https://developers.facebook.com/docs/php/FacebookRedirectLoginHelper/4.0.0
"Then, in your callback page (at the redirect url) when Facebook sends the user back:
$helper = new FacebookRedirectLoginHelper($redirect_url);
try {
$session = $helper->getSessionFromRedirect();
} catch(FacebookRequestException $ex) {
// When Facebook returns an error
} catch(\Exception $ex) {
// When validation fails or other local issues
}
if ($session) {
// Logged in.
}
You need a way to capture the response from the RedirectLoginHelper, and use it to generate the FacebookSession. You can use getSessionFromRedirect(), or manually process the POST data from Facebook. It's up to you, but as of now, you are doing neither.
@s1dd, Thank u for ur reply. How can I manually process the $_POST data?
I highly recommend using getSessionFromRedirect as it abstracts the pain of using the $_POST superglobal; however, if you're insistent on not using this method, I would just start by using a dd($_POST) to try and find the token in the response, and then save it to the session. I would suggest reading through the Facebook documentation for access tokens, as well as the PHP SDK to help gain a better understanding of how the RedirectLoginHelper works.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community