首页 > 解决方案 > 如何使用 Linkedin Api 获取所有 Linkedin 个人资料帖子

问题描述

我需要 LinkedIn API 来显示我从第一天开始发布的个人资料的提要。帖子包括媒体、图片、视频等。

我曾尝试使用 LinkedIn /share端点,但它返回如下错误,

https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/share-api?tabs=http#find-shares-by-owner

[serviceErrorCode] => 0
[message] => Tunneled request must have 'Content-Type' header set to 'application/x-www-form-urlencoded' or 'multipart/mixed'
[status] => 400

这是代码:

$url="https://api.linkedin.com/v2/shares?q=owners&owners=urn:li:person:".$linked_profile['id'];
$headers[] = 'X-HTTP-Method-Override: BATCH_GET';
$headers[] = 'X-Restli-Protocol-Version: 2.0.0';
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
$headers[] = 'Authorization: Bearer ' .$_SESSION['linkedin_access_token'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close($ch); 
$result = json_decode($result,true);

如果有人以前这样做过,请提供帮助。谢谢。

标签: phpcurllinkedinlinkedin-api

解决方案


推荐阅读