Juliano
Juliano

Reputation: 65

How can I get first name and last name from Facebook using Laravel Socialite?

How can I get first name and last name from Facebook using Laravel Socialite? By default I'm getting full name in a single field.

Upvotes: 2

Views: 2377

Answers (2)

nlagdhir
nlagdhir

Reputation: 41

You can get field from provider like this.

//get the driver and set desired fields
$driver = Socialite::driver('facebook')
->fields(['name', 'first_name', 'last_name', 'email', 'gender', 'verified']);

// retrieve the user
$user = $driver->user();

follow this link for more details

Laravel Socialite first and last name

Upvotes: 0

Juliano
Juliano

Reputation: 65

 Socialite::driver('facebook')->fields(['first_name', 'last_name'])->user();

Upvotes: 3

Related Questions