LinkedIn API 403 - "访问发布的内容被拒绝"

时间:2016-08-10 15:50:35

标签: php json linkedin http-status-code-403 linkedin-api

我正在开发一个PHP功能,以便在我公司的框架上自动分享关于Linkedin的用户提要的新文章。身份验证工作,所以令牌正在工作(我可以在共享时从LinkedIn获取我的名字和姓氏),但我一直收到 403错误"访问帖子被拒绝" 在共享文章时的POST结果中。

在我的应用程序参数" r_basicprofile"和" w_share"检查。但是,当我创建授权URL时,我会重新添加这些范围参数(我使用linkedin-php by splashmedia进行连接)。我还在我的LinkedIn应用程序上以管理员和开发者权限的身份连接用户。但我仍然不能在自己的饲料上分享一篇文章。

这是我的代码失败的部分。我在AJAX中,所以如果我在console.log中生成了URL,它是有效的,但会以JSON格式返回403错误消息。

/* Create API request to share an article */

//Building up the URL
$url = 'https://api.linkedin.com/v1/people/~/shares?&oauth2_access_token='.$_SESSION['linkedInCreds']['access_token'].'&format=json&message='.rawurlencode($_REQUEST['message']).'&visibility[code]='.$_REQUEST['visibility']['code'];
    $options = array(
        'http' => array(
            'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
            'method'  => 'POST',
            'content' => http_build_query($url)
        )
    );


$context = stream_context_create($options);
$result = file_get_contents($url, false, $context); /***** FAILS: Returns JSON with 403 error code from LinkedIn. *****/

/* Check if $result is true or false and echoes the result. End of AJAX. */

我目前仍然坚持这个问题。显然这个功能并没有被LinkedIn取消,但是我无法让它发挥作用,任何人都可以帮忙吗?

提前致谢。

0 个答案:

没有答案
相关问题