本文介绍了LinkedIn Rich Media Shares API 错误“权限不足,无法访问媒体资源"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

{服务错误代码":100,"message":"没有足够的权限访问媒体资源",状态":403}

这是请求代码示例

$curl = curl_init();curl_setopt_array($curl, 数组(CURLOPT_URL =>"https://api.linkedin.com/media/upload",CURLOPT_RETURNTRANSFER =>真的,CURLOPT_ENCODING =>"",CURLOPT_MAXREDIRS =>10、CURLOPT_TIMEOUT =>30,CURLOPT_HTTP_VERSION =>CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST =>邮政",CURLOPT_POSTFIELDS =>————WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-数据;名称=\"来源\";文件名=\"iphone5.jpeg\"\r\n内容类型:图像/jpeg\r\n[**image_binary_data**]\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",CURLOPT_HTTPHEADER =>大批(授权:持有人[**访问令牌**]",缓存控制:无缓存",内容类型:多部分/表单数据;边界=----WebKitFormBoundary7MA4YWxkTrZu0gW"),));$response = curl_exec($curl);$err = curl_error($curl);curl_close($curl);如果($错误){echo "cURL 错误 #:" .$错误;} 别的 {回声 $response;}

谢谢

解决方案

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

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

I have LinkedIn app (Created from here https://www.linkedin.com/developer/apps) with scope of r_basicprofile, r_emailaddress, rw_company_admin, w_share

After completing auth process successfully i got access token from linkedin api and it's working to get authenticated user information.

But while i try to use Rich Media Shares API then it's not working for meI am getting following error

Here is the request code sample

$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;
}

Thanks

解决方案

You need to be a LinkedIn developer "Partner" in order to access the "media" controller/endpoint:

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

这篇关于LinkedIn Rich Media Shares API 错误“权限不足,无法访问媒体资源"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 04:18