2014-01-07 39 views
1

我想在PHP上使用API​​發佈LinkedIn上的工作,但是當我發送請求時,它會拋出403錯誤。錯誤消息是:如何使用PHP中的API在LinkedIn上發佈工作?

寫入權限被拒絕。

我的代碼有什麼問題?

$status_url = 'https://api.linkedin.com/v1/jobs'; 
$xml = file_get_contents('http://developer.linkedin.com/sites/default/files/job.xml'); 
$request = OAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "POST", $status_url); 
$request->sign_request($this->signature_method, $this->consumer, $this->access_token); 
$auth_header = $request->to_header("https://api.linkedin.com"); 
$response = $this->httpRequest($status_url, $auth_header, "POST", $xml); 


function httpRequest($url, $auth_header, $method, $body = NULL) 
{ 
    $curl = curl_init(); 
    curl_setopt($curl, CURLOPT_URL, $url); 
    curl_setopt($curl, CURLOPT_HEADER, 0); 
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($curl, CURLOPT_POST, 1); 
    curl_setopt($curl, CURLOPT_POSTFIELDS, $body); 
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); 
    curl_setopt($curl, CURLOPT_HTTPHEADER, array($auth_header, "Content-Type: text/xml;charset=utf-8")); 
    $data = curl_exec($curl); 
    curl_close($curl); 
    return $data; 
} 

爲什麼它不起作用?

回答

0

您需要聯繫LinkedIn併成爲「合作伙伴」,因爲這是一個封閉的API。 source

+0

這不會提供問題的答案。要批評或要求作者澄清,在他們的帖子下留下評論 - 你總是可以評論你自己的帖子,一旦你有足夠的[聲譽](http://stackoverflow.com/help/whats-reputation),你會能夠[評論任何帖子](http://stackoverflow.com/help/privileges/comment)。 – sina72

+0

@ sina72對我來說,這看起來像是一個有效的答案。但是,如果艾倫可以添加鏈接來備份她聲稱API現在已關閉的聲明,將會有所幫助。 –

+0

應該有一個citiation /鏈接來提供關於API的關閉狀態的確認。 – kguest

相關問題