I'm facing one issue while sending messages to linked connections. I have used two APIs, https://api.linkedin.com/v1/people/ to update profile and https://api.linkedin.com/v1/people/~/mailbox to sending messages to connections.
Updating the profile is working fine for me, and I am even getting one 1-level connection. But the problem is arising when sending messages to connections.
Below is the XML code I'm using to send messages.
$xmlPostData = '<?xml version="1.0" encoding="UTF-8"?>
<mailbox-item>
<recipients>
<recipient>
<person path="/people/'.$iMemberId.'" />
</recipient>
</recipients>
<subject>Invitation to Connect</subject>
<body>Please Join On Eduroadmap</body>
<item-content>
<invitation-request>
<connect-type>friend</connect-type>
<authorization>
<name>'.$sAuthName.'</name>
<value>'.$sAuthValue.'</value>
</authorization>
</invitation-request>
</item-content>
</mailbox-item>';
In above code, $iMemberId, $sAuthName , $sAuthValue are the connection details which I have retrieved from https://api.linkedin.com/v1/people/~/connections api.
Below is the curl I am using to post the above XML.
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$sUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$xmlPostData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
In the above code, $sUrl is => https://api.linkedin.com/v1/people/~/mailbox?oauth2_access_token=, and I'm appending an access token that is correct I am sure.
What am I missing? I have tried a lot, but I found nothing.