尝试访问公司更新时出现“成员 0 无权获取公司”错误LinkedIn


"Member 0 does not have permission to get company" error when trying to access LinkedIn company updates

在我通过LinkedIn的开发人员后端创建应用程序后,我已经让客户端批准我的用户为管理员。我什至让客户端创建了自己的应用程序并为我提供了客户端密钥,但是每次尝试提取公司更新时,我都会收到相同的错误消息:

"成员 0 无权获取公司 1311XXX"

这是我对该页面的代码:

$config['base_url']             =   'http://www.hiddenlink.com/resources/li-oauth-src/auth.php';
$config['callback_url']         =   'http://www.hiddenlink.com/resources/li-oauth-src/demo.php';
$config['linkedin_access']      =   '770lXXXXXXXXXX';
$config['linkedin_secret']      =   'hcxpOtXXXXXXXXXX';
include_once "linkedin.php";
# First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback
$linkedin = new LinkedIn($config['linkedin_access'], $config['linkedin_secret'], $config['callback_url'] );
//$linkedin->debug = true;
if (isset($_REQUEST['oauth_verifier'])){
    $_SESSION['oauth_verifier']     = $_REQUEST['oauth_verifier'];
    $linkedin->request_token    =   unserialize($_SESSION['requestToken']);
    $linkedin->oauth_verifier   =   $_SESSION['oauth_verifier'];
    $linkedin->getAccessToken($_REQUEST['oauth_verifier']);
    $_SESSION['oauth_access_token'] = serialize($linkedin->access_token);
    header("Location: " . $config['callback_url']);
    exit;
}
else{
    $linkedin->request_token    =   unserialize($_SESSION['requestToken']);
    $linkedin->oauth_verifier   =   $_SESSION['oauth_verifier'];
    $linkedin->access_token     =   unserialize($_SESSION['oauth_access_token']);
}
$json_response = $linkedin->getCompanyUpdates("1311XXX");
$json = json_decode($json_response);
echo "<pre>";
print_r($json);
echo "</pre>";
for($x = 0; $x < 2; $x++){
    $json_value = $json->values[$x];
    $articleURL = $json_value->updateContent->companyStatusUpdate->share->content->eyebrowUrl;
    $postTitle = $json_value->updateContent->companyStatusUpdate->share->content->title;
    $description = htmlspecialchars($json_value->updateContent->companyStatusUpdate->share->content->description);
    $timestamp = $json_value->updateContent->companyStatusUpdate->share->timestamp;
    echo '<pre>';
    print_r($description);
    echo '<br />';
    print_r($articleURL);
    echo '<br />';
    print_r($postTitle);
    print_r(date("jS M, Y", $timestamp));
    echo '</pre>';
}

下面是为 json_response 变量调用的 getCompanyUpdates 函数的代码:

function getCompanyUpdates($id){
    $updateURL = $this->base_url . "/v1/companies/" . $id . "/updates?format=json";
    $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "GET", $updateURL);
    $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
    $auth_header = $request->to_header("https://api.linkedin.com"); # this is the realm
    $response = $this->httpRequest($updateURL, $auth_header, "GET");
    return $response;
}
我不知道我做错了

什么,但很明显我做错了什么。任何帮助将不胜感激

您似乎没有在 oauth 工作流中的任何位置显式传递范围值,因此我只能假设您依赖于正确配置LinkedIn应用程序的默认范围值。

检查以确保在尝试进行该 API 调用时请求rw_company_admin成员权限。