0
我通過LinkedIn的開發者後端創建我的應用程序後,我的客戶已經以管理員身份批准了我的用戶。我甚至讓客戶創建他們自己的應用程序,併爲我提供客戶端密鑰,但是每次嘗試公司更新時都會收到相同的錯誤消息:當試圖訪問LinkedIn公司更新時,「成員0無權獲取公司」
「成員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;
}
我沒有線索我做錯了什麼,但很明顯我做錯了什麼。任何幫助將不勝感激
[LinkedIn API無法查看\ _any \ _公司配置文件]的可能重複(http://stackoverflow.com/questions/30409219/linkedin-api-unable-to-view-any-company-profile) – Ben