0

How can I sent a custom field in socialize laravel in RedirectToProvider method using this method:

if ($social == 'facebook') {
    return Socialize::with($social)->fields([
                'first_name', 'last_name', 'email', 'gender', 'birthday'
            ])->scopes([
                'email', 'user_birthday'
            ])->redirect();
}

suppose i want to send network_id => 9.

And then how can I get it in my handler method where I am getting user information?

$user = Socialize::with('facebook')->user();
Ben Swinburne
  • 25,669
  • 10
  • 69
  • 108
rehan aziz
  • 64
  • 1
  • 8

2 Answers2

0

Only way i found to get the parameters using Socialite is storing it in the Session

public function redirectToFacebookProvider()
{
    // save anything you will need later, for example an url to come back to
    Session::put('url.intended', URL::previous());

    return Socialite::driver('facebook')->redirect(); 
}

public function handleFacebookProviderCallback()
{
    // handling....

    $url = Session::get('url.intended', url('/'));
    Session::forget('url.intended');

    return redirect($url);
}

Obtained this answer from https://laracasts.com/discuss/channels/laravel/socialite-return-parameters-in-callback?page=0

Sr.PEDRO
  • 1,664
  • 19
  • 21
-1

Use

$user = Socialite::driver('facebook')->user();

And then retrieve items from the $user array, like so

$user['email']