How to post a job on LinkedIn using the API in PHP

2019-08-05 01:22发布

I want to post a job on LinkedIn using the API in PHP, but when I send the request it throws me a 403 error. The error message is:

Write access to job posting denied.

What is wrong with my code?

$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;
}

Why is it not working?

1条回答
【Aperson】
2楼-- · 2019-08-05 02:06

You need to contact LinkedIn and become a "Partner" as this is a closed API now. source

查看更多
登录 后发表回答