访问被拒绝调用LinkedIn的API

时间:2015-03-16 15:22:41

标签: php http curl get linkedin

我按照步骤设置了访问令牌(LinkedIn developer)。但是,当我调用搜索人员的API时出现错误。

这是我的代码;

Route::post('research', function()

{
    $c = curl_init();
    $firstName = Request::input('firstName'); $lastName = Request::input('lastName');
    $resource = '&first-name='.$firstName.'&last-name='.$lastName.'&sort=connections';
    $params = array(
        'oauth2_access_token' => Session::get('access_token'),
        'format' => 'json',
    );
    $postdata = http_build_query($params);
    $url = 'https://api.linkedin.com/v1/people-search?'.$postdata.$resource;
    curl_setopt($c, CURLOPT_URL, $url);
    curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($c, CURLOPT_HEADER, true);
    $output = curl_exec($c);
    if($output === false)
    {
        trigger_error('Erreur curl : '.curl_error($c),E_USER_WARNING);
        exit('error');
    }else{
        var_dump($output);
        exit('result');
    }
    curl_close($c);
});

这是我的错误;

{
  "errorCode": 0,
  "message": "Access to people search denied.",
  "requestId": "DHYNQTZDN8",
  "status": 403,
  "timestamp": 1426519095912
}

有人可以建议我找一个解决方案吗?

提前感谢David Meurisse

1 个答案:

答案 0 :(得分:0)

您需要LinkedIn的特别许可才能使用People Search API。 https://developer-programs.linkedin.com/documents/people-search-api