PHP code example of reverse / linkedin-php

1. Go to this page and download the library: Download reverse/linkedin-php 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/ */

    

reverse / linkedin-php example snippets


$client = new Client('appId', 'appSecret', 'returnUrl');

$client = new Client('appId', 'appSecret', 'returnUrl');
if (array_key_exists('code', $_GET)) {
    $client->initToken($_GET['code']);
    
    $me = new Me($client);
} else {
    $authUrl = $client->getAuthenticationUrl([
        'scope' => [Client::PERMISSION_LITE_PROFILE]
    ]);
    header('Location: '.$authUrl);
    exit;
}

$client = new Client('appId', 'appSecret', 'returnUrl');
if (array_key_exists('code', $_GET)) {
    $client->initToken($_GET['code']);
    
    $shares = new Shares();
    $shares->setResharedShare('urn:li:share:1232132') // Post's urn:id
    
    $shares->setOwner('urn:li:person:c7RFYxyz78')
    
    $shareText = new ShareText();
    $shareText->setTitle('my title');
    
    $shares->setText($shareText);
    
    $shareEndpoint = new REverse\LinkedIn\Endpoint\Share($client);
    $shareEndpoint->postShares($shares);
} else {
    $authUrl = $client->getAuthenticationUrl([
        'scope' => [Client::PERMISSION_LITE_PROFILE, Client::PERMISSION_W_MEMBER_SOCIAL]
    ]);
    header('Location: '.$authUrl);
    exit;
}