PHP code example of scottybo / laravel-linkedin-v2
1. Go to this page and download the library: Download scottybo/laravel-linkedin-v2 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
if (LinkedInV2::isAuthenticated()) {
//we know that the user is authenticated now. Start query the API
$user=LinkedIn::get('v2/me');
echo "Welcome ".$user['firstName'];
exit();
}elseif (LinkedInV2::hasError()) {
echo "User canceled the login.";
exit();
}
//if not authenticated
$url = LinkedInV2::getLoginUrl();
echo "<a href='$url'>Login with LinkedIn</a>";
exit();
// By setter
LinkedInV2::setFormat('xml');
// Set format for just one request
LinkedInV2::post('v1/people/~/shares', array('format'=>'xml', 'body'=>$body));
// By setter
LinkedInV2::setResponseDataType('simple_xml');
// Set format for just one request
LinkedInV2::get('v2/me', array('response_data_type'=>'psr7'));