我想使用PHP中的API在LinkedIn上发布作业,但是当我发送请求时,它会抛出403错误。错误消息是:
写入拒绝职位发布的访问权限。
我的代码出了什么问题?
$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;
}
为什么不起作用?