Linkedin ';资源me不存在';调用/v2/me时发生API错误

Linkedin ';资源me不存在';调用/v2/me时发生API错误,linkedin,linkedin-api,Linkedin,Linkedin Api,当我尝试调用URL GET:/v2/me时,收到错误“资源me不存在” 获取: 从以下地址接收令牌: 授权URL: $url = 'https://www.linkedin.com/oauth/v2/authorization' .'?response_type=code' .'&client_id='."77uuvjhz11mi71" .'&redirect_uri='."http://localhost/linkedin"

当我尝试调用URL GET:/v2/me时,收到错误“资源me不存在”

获取:

从以下地址接收令牌:

授权URL:

$url = 'https://www.linkedin.com/oauth/v2/authorization'
        .'?response_type=code'
        .'&client_id='."77uuvjhz11mi71"
        .'&redirect_uri='."http://localhost/linkedin"
        .'&state=123123123'
        .'&scope=r_liteprofile%20r_emailaddress%20w_member_social';
请求:

...
$linkedin->getAccessToken($_GET['code']);
...
$this->setMethod("GET");
$this->setUrl("https://api.linkedin.com/v2/me?projection=(id,firstName,lastName,profilePicture)");
$this->setHeaders([
    "Authorization: Bearer ".$this->accessToken,
]);
$resp = $this->sendRequest();
答复:

{#81 ▼
  +"serviceErrorCode": 0
  +"message": "Resource me does not exist"
  +"status": 404
}
API函数:

public function __construct()
{
    $this->ch = curl_init();
}
public function sendRequest()
{
    curl_setopt_array($this->ch, $this->options);
    $result = curl_exec($this->ch);

    if (curl_errno($this->ch)) {
        throw new Exception("Error ". curl_error($this->ch), 1);
    }

    $json = json_decode($result);

    return $json;
}
public function setMethod(String $method)
{
    $method = strtoupper($method);

    if ($method === "POST") {
        $this->options[CURLOPT_POST] = true;
    }

    return $this;
}
public function setUrl(String $url)
{
    $this->options[CURLOPT_URL] = $url;

    return $this;
}
public function setHeaders(Iterable $headers)
{
    $this->options[CURLOPT_HTTPHEADER] = $headers;

    return $this;
}
public function getAccessToken($code)
{
    $this->setMethod("POST");
    $this->setUrl("https://www.linkedin.com/oauth/v2/accessToken");
    $this->setPostFields([
            "grant_type" => "authorization_code",
            "code" => $code,
            "redirect_uri" => "http://localhost/test",
            "client_id" => $this->clientId,
            "client_secret" => $this->clientSecret,
    ]);
    $resp = $this->sendRequest();
    $this->accessToken = $resp->access_token;
}

回调函数中会出现什么类型的错误?请共享一些代码,以便我们可以尝试重现问题。您好,我更改了问题并添加了代码以及从服务器获得的详细响应。可能是权限问题。检查在创建访问令牌时是否需要这些:r_basicprofile、r_liteprofile(这些令牌包含权限)。您还可以尝试使用curl:
curl-H'Authorization:Bearer…TOKEN…''发出请求https://api.linkedin.com/v2/me“
回调函数中会出现什么类型的错误?请共享一些代码,以便我们可以尝试重现问题。您好,我更改了问题并添加了代码以及从服务器获得的详细响应。可能是权限问题。检查在创建访问令牌时是否需要这些:r_basicprofile、r_liteprofile(这些令牌包含权限)。您还可以尝试使用curl:
curl-H'Authorization:Bearer…TOKEN…''发出请求https://api.linkedin.com/v2/me“