我正在爲我的最新項目使用https://github.com/artdarek/oauth-4-laravel。我能夠使用此工具實現LinkedIn OAuth,但發佈共享不起作用。這裏是我的代碼:Artdarek oauth-4-laravel/Lusitanian/PHPoAuthLib:張貼LinkedIn共享API不工作
$params['content'] ='
<share>
<comment>Check out the LinkedIn Share API!</comment>
<content>
<title>LinkedIn Developers Documentation On Using the Share API</title><description>Leverage the Share API to maximize engagement on user-generated content on LinkedIn</description>
<submitted-url>https://developer.linkedin.com/documents/share-api</submitted-url>
<submitted-image-url>http://m3.licdn.com/media/p/3/000/124/1a6/089a29a.png</submitted-image-url>
</content>
<visibility>
<code>connections-only</code>
</visibility>
</share>';
$extraHeaders = array(
'Content-type' => 'application/xml',
);
$status = json_decode($linkedinService->request('people/~/shares?format=json', 'POST',
$params, $extraHeaders));
但發佈不起作用。但我可以發帖使用cURL,所以我認爲我的access_token是可以的。這是我的cURL代碼
$handle = curl_init();
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($handle, CURLOPT_URL, "https://api.linkedin.com/v1/groups/{$post->linkedInGroupAccount->linkedin_id}/posts?format=json&oauth2_access_token={$post->linkedInGroupAccount->access_token}");
curl_setopt($handle, CURLOPT_VERBOSE, TRUE);
$header[] = 'Content-Type: text/xml; charset=UTF-8';
curl_setopt($handle, CURLOPT_POSTFIELDS, $content);
curl_setopt($handle, CURLOPT_HTTPHEADER, $header);
$post->msg = curl_exec($handle);
curl_close($handle)
爲什麼$ linkedinService-> request()不起作用?
我知道這已經有一段時間了,但是你有沒有解決過這個問題?如果是,如何? – ericbae