LinkedIn Rich Media共享API错误'没有足够的权限访问媒体资源'

时间:2018-01-23 10:07:18

标签: php rest api curl linkedin-api

我有LinkedIn应用(从这里创建https://www.linkedin.com/developer/apps),其范围为 r_basicprofile,r_emailaddress,rw_company_admin,w_share

成功完成身份验证过程后,我从linkedin API获取访问令牌,并且正在努力获取经过身份验证的用户信息。

但是当我尝试使用 Rich Media共享 API时,它对我不起作用 我收到了以下错误

{

   "serviceErrorCode":100,

   "message":"Not enough permissions to access media resource",

   "status":403

}

这是请求代码示例     

$curl = curl_init();

curl_setopt_array($curl, array(
 CURLOPT_URL => "https://api.linkedin.com/media/upload",
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_ENCODING => "",
 CURLOPT_MAXREDIRS => 10,
 CURLOPT_TIMEOUT => 30,
 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
 CURLOPT_CUSTOMREQUEST => "POST",   
 CURLOPT_POSTFIELDS => "------
    WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-
    data; name=\"source\"; filename=\"iphone5.jpeg\"\r\nContent-Type: 
    image/jpeg\r\n[**image_binary_data**]\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
 CURLOPT_HTTPHEADER => array(
    "authorization: Bearer [**accesstoken**]",
    "cache-control: no-cache",
    "content-type: multipart/form-data; boundary=----
       WebKitFormBoundary7MA4YWxkTrZu0gW"
 ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

由于

1 个答案:

答案 0 :(得分:3)

您需要成为LinkedIn开发人员"合作伙伴"为了访问"媒体"控制器/端点:

https://developer.linkedin.com/partner-programs