0

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

“成员 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;
}

我对自己做错了什么一无所知,但很明显我做错了什么。任何帮助将非常感激

4

1 回答 1

1

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

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

于 2015-06-12T22:40:02.030 回答