Paka Information

Auto Post On LinkedIn Using PHP script

961 0

Auto Post On LinkedIn Using PHP script

Today, We want to share with you Auto Post On LinkedIn Using PHP script.
In this post we will show you Automatically Post Content To LinkedIn Using PHP, hear for Adding a post : Auto Post On LinkedIn Using PHP we will give you demo and example for implement.
In this post, we will learn about Automatically post to a LinkedIn page using the LinkedIn PHP API with an example.

LinkedIn Get Access Token using PHP

You can Best Way to get the LinkedIn Access Token by follow the Step By Step of This Link Get Access Tokens – LinkedIn Login – LinkedIn for Developers in serialized form.

get user access token for linkedin 4

get user access token for linkedin 4

Auto Post on LinkedIn using PHP Script

First of all for the Simple Example of the LinkedIn Auto Post script make a PHP file autopost.php and then Copy Past the following below Source code:

Also Read :  All Mobile Network SIM And Internet Balance

//include here OAuth.php File
require_once("OAuth.php");
 
$config = array(
    'consumer_key' => '{YOUR_LIVE_CLIENT_ID}',
    'consumer_secret' => '{YOUR_KEY_OF_THE_CLIENT_SECRET}',
    'callback_url' => ''
);
 
$req_mthd = new OAuthSignatureMethod_HMAC_SHA1();
$live_consume = new OAuthConsumer($config['consumer_key'], $config['consumer_secret']);
 
$access_token = unserialize($access_token); 

<a href="<a class="vglnk" href="http://pakainfo.com/jobs/technology/php-linkedin-authentication-accesstoken-linkedin-oauth-2-0/" rel="nofollow"><span>http</span><span>://</span><span>www</span><span>.</span><span>pakaInfo</span><span>.</span><span>com</span><span>/</span><span>2020</span><span>/</span><span>09</span><span>/</span><span>get</span><span>-</span><span>user</span><span>-</span><span>access</span><span>-</span><span>token</span><span>-</span><span>for</span><span>-</span><span>linkedin</span></a>" target="_blank"><strong>get user Access Token for LinkedIn</strong></a>
 
$title = "Auto Post On Blogspot Using PHP script";
$YourtargetURI = "<a class="vglnk" href="http://pakainfo.com/jobs/technology/google/auto-post-blogspot-using-php-script/" rel="nofollow"><span>http</span><span>://</span><span>www</span><span>.</span><span>pakaInfo</span><span>.</span><span>com</span><span>/</span><span>2020</span><span>/</span><span>09</span><span>/</span><span>auto</span><span>-</span><span>post</span><span>-</span><span>on</span><span>-</span><span>linkedin</span><span>-</span><span>using</span><span>-</span><span>php</span><span>-</span><span>oauth</span></a>";
$imgUrl = "<a class="vglnk" href="http://pakainfo.com/wp-content/uploads/2018/01/get-user-access-token-for-linkedin-4.png" rel="nofollow"><span>http</span><span>://</span><span>www</span><span>.</span><span>pakaInfo</span><span>.</span><span>com</span><span>/</span><span>wp</span><span>-</span><span>content</span><span>/</span><span>uploads</span><span>/</span><span>2020</span><span>/</span><span>09</span><span>/</span><span>Auto</span><span>-</span><span>Post</span><span>-</span><span>on</span><span>-</span><span>LinkedIn</span><span>-</span><span>Using</span><span>-</span><span>PHP</span><span>-</span><span>OAuth</span><span>.</span><span>png</span></a>";
$description= "PakaInfo was founded in January 2018. We deliver Jobs, Earn Money, Education, Health, Technology, Life Style, Science, Top10 and Nature.";
 
$live_pakainfo_url = "<a class="vglnk" href="http://api.linkedin.com/v1/people/~/shares" rel="nofollow"><span>http</span><span>://</span><span>api</span><span>.</span><span>linkedin</span><span>.</span><span>com</span><span>/</span><span>v1</span><span>/</span><span>people</span><span>/~/</span><span>shares</span></a>";
$xml = "<share>";
$xml .= "<content>
<title>$title</title>
<description>$description</description>";
if(!empty($YourtargetURI)){
    $xml .= "<submitted-url>$YourtargetURI</submitted-url>";
}
 
if(!empty($imgUrl)){
    $xml .= "<submitted-image-url>$imgUrl</submitted-image-url>";
}
$xml .= "</content>
  <visibility>
    <code>anyone</code>
  </visibility>
</share>";
 
$live_req = OAuthRequest::from_consumer_and_token($live_consume, $access_token, "POST", $live_pakainfo_url);
$live_req->sign_request($req_mthd, $live_consume, $access_token);
$linkdin_auth_head = $live_req->to_header("<a class="vglnk" href="https://api.linkedin.com" rel="nofollow"><span>https</span><span>://</span><span>api</span><span>.</span><span>linkedin</span><span>.</span><span>com</span></a>");
 
$response = httpRequest($live_pakainfo_url, $linkdin_auth_head, "POST", $xml);
 
function httpRequest($url, $linkdin_auth_head, $req_mthd, $body = NULL) {
    if (!$req_mthd) {
        $req_mthd = "GET";
    }
 
    $live_ch = curl_init();
    curl_setopt($live_ch, CURLOPT_URL, $url);
    curl_setopt($live_ch, CURLOPT_HEADER, 0);
    curl_setopt($live_ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($live_ch, CURLOPT_HTTPHEADER, array($linkdin_auth_head)); // Set the all Your LinkedIn headers.
 
    if ($body) {
        curl_setopt($live_ch, CURLOPT_POST, 1);
        curl_setopt($live_ch, CURLOPT_POSTFIELDS, $body);
        curl_setopt($live_ch, CURLOPT_CUSTOMREQUEST, $req_mthd);
        curl_setopt($live_ch, CURLOPT_HTTPHEADER, array($linkdin_auth_head, "Content-Type: text/xml;charset=utf-8"));  
    }
 
    $resData = curl_exec($live_ch);
    curl_getinfo($live_ch, CURLINFO_HTTP_CODE);
    curl_close($live_ch);
    return $resData;
}

You can Display this in your All the LinkedIn activities. Here is the Latest My LinkedIn screen of the Share Data or Logo content shared on the Live Users using LinkedIn account.

Auto Post On LinkedIn Using PHP script

Auto Post On LinkedIn Using PHP script

We hope you get an idea about Auto post into LinkedIn using php Source code
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.

Also Read :  Auto Post on Facebook Page using Facebook PHP API

We hope This Post can help you…….Good Luck!.

Leave A Reply

Your email address will not be published.