
In this blog, I am going to explain How to Login from PHP using LinkedIn API. So, before you go to XAMPP folder’s htdocs and create a new folder. After that, click right button and select “Git bash Here” and
type -“composer require guzzlehttp/guzzle:^7.0” after that auto-create composer, guzzlehttp, autoloader & some important file. After that, create a file as index.php as shown below- You can use extra CSS for attractive



<?php | |
require "config.php"; | |
?> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>login from PHP using LinkedIn API</title> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> | |
<style> | |
body, html { | |
height: 100%; | |
} | |
.bg { | |
background-image: url("/images/bg.jpg"); | |
height: 100%; | |
background-position: center; | |
background-repeat: no-repeat; | |
background-size: cover; | |
} | |
</style> | |
</head> | |
<body class="bg"> | |
<div class="container"> | |
<br><br><br> | |
<div class="row"> | |
<div class="col-6 offset-3" style="margin: auto;background: white; padding: 20px; box-shadow: 10px 10px 5px #888;"> | |
<div class="panel-heading"> | |
<h4>login from PHP using LinkedIn API</h4> | |
<p style="font-style: italic;">Using LinkedIn API v2</p> | |
</div> | |
<hr> | |
<div class="panel-body"> | |
<a href="<?php echo $linkedin->getAuthUrl() ?>" class="btn btn-primary btn-block">Sign In with LinkedIn</a> | |
</div> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
These are folder after install Composer

This is form of Index.php
After that, create another file like “config.php” and type shown below-
<?php | |
session_start(); | |
require "vendor/autoload.php"; | |
require "LinkedIn.php"; | |
use ajForm\LinkedIn; | |
$app_id = "type_App_Id"; | |
$app_secret = "Type_App_Secret"; | |
$app_callback = "http://localhost/callback.php"; | |
$app_scopes = "r_emailaddress r_liteprofile w_member_social"; | |
$ssl = false; // ALWAYS TRUE FOR PRODUCTION USE | |
$linkedin = new LinkedIn($app_id, $app_secret, $app_callback, $app_scopes, $ssl); | |
// var_dump($linkedin); | |
// die(); | |
?> |
After that, you will be required Client ID, and Client Secret, so these before going to https://www.linkedin.com/ developers and create app and fillup this form and create APP.



When you create App id after that provide Client id & Client Secret in Config.php file and run index.php file in your browser before run you start XAMPP then will be run your index file like shown upper sign page and click sign in then next Sign in and Allow Login.






I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND