I am trying to fetch all the public details of a Linkedin user. but failed again and again. i am using Laravel framework. it is very easy to integrate socialite in Laravel and i also implement that. i authorized user and fetch its name email and profile image. but i also want to fetch its location ,Eduction Experience and other public stuff how can i do it. i also Attach my code with my post and image too for reference. what i am fetching right now
Socialite Package Used
composer require laravel/socialite
config/services.php i all ready set these details in .env file and also in config/servies.php file
'Linkedin' => [
'client_id' => env('Linkedin_CLIENT_ID'),
'client_secret' => env('Linkedin_CLIENT_SECRET'),
'redirect' => 'http://your-callback-url',
],
My Controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Socialite;
use Redirect;
class AuthController extends Controller
{
public function redirectToLinkedin()
{
return Socialite::driver('linkedin')->redirect();
}
public function handleLinkedinCallback()
{
//$scope = array('r_fullprofile');
$data = Socialite::driver('linkedin')->user();
// $user = Socialite::driver('linkedin')->user();
// $create['name'] = $user->name;
// $create['email'] = $user->email;
// $create['linkedin_id'] = $user->id;
echo "<pre>";
print_r($data1);
}
}
My View
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Login</div>
<div class="panel-body">
<form class="form-horizontal" role="form" method="POST" action="{{ url('/login') }}">
{!! csrf_field() !!}
<div class="form-group">
<label class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input type="email" class="form-control" name="email" value="{{ old('email') }}">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input type="password" class="form-control" name="password">
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<div class="checkbox">
<label>
<input type="checkbox" name="remember"> Remember Me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<a href="{{ url('auth/linkedin') }}" class="btn btn-primary">
<strong>Login With Linkedin</strong>
</a>
<button type="submit" class="btn btn-primary">
Login
</button>
<a class="btn btn-link" href="{{ url('/password/reset') }}">Forgot Your Password?</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
My Routes
Route::get('link', function () {
return view('link');
});
Route::get('auth/linkedin', 'AuthController@redirectToLinkedin');
Route::get('auth/linkedin/callback', 'AuthController@handleLinkedinCallback');