Skip to content

Instantly share code, notes, and snippets.

@neilbradley
Created August 4, 2017 12:58
Show Gist options
  • Save neilbradley/7d5d0937771afcf8b6f9d0d068a94448 to your computer and use it in GitHub Desktop.
Save neilbradley/7d5d0937771afcf8b6f9d0d068a94448 to your computer and use it in GitHub Desktop.
Lever API Job Posting example
<?php
// http://s20493.p303.sites.pressdns.com/job-details/?id=9f89449a-451c-4e50-8f4a-8b92c6a0a7e1
global $val;
$val = "9f89449a-451c-4e50-8f4a-8b92c6a0a7e1";//posting id
function post_to_url($url, $data)
{
$post = curl_init();
curl_setopt($post, CURLOPT_URL, $url);
curl_setopt($post, CURLOPT_POST, count($data));
curl_setopt($post, CURLOPT_POSTFIELDS, $data);
curl_setopt($post, CURLOPT_HEADER, 1);
curl_setopt($post, CURLOPT_HTTPHEADER, array(
'Content-Type: multipart/form-data'
));
curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($post);
if (!curl_errno($post)) {
$info = curl_getinfo($post);
if ($info['http_code'] == 200) {
echo "Success";
} else {
echo "Failure";
}
} else {
$errmsg = curl_error($post);
}
curl_close($post);
}
$data = array(
"name" => "Lever Support",
"email" => "jane@example.com",
"phone" => "123 456 7890",
"resume" => curl_file_create("Resume.docx"),
"org" => "ExampleCo",
"urls[LinkedIn]" => "https://www.linkedin.com/in/zeus-lalkaka-25864755",
"urls[Twitter]" => "https://twitter.com/distracteddev",
"urls[Github]" => "https://github.com/distracteddev",
"urls[Portfolio]" => "https://zeus.ly",
"urls[Other]" => "https://google.com",
"comments" => "This candidate was created as a test by Lever Support"
);
$url = 'https://api.lever.co/v0/postings/grab/' . $val . '?key=hbQkdxoTlo7WkAIvO_Eb';
post_to_url($url, $data);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment