[insert_php]
session_start();
try {
function get_jobs($baseURL = ”, $method, $options = array(), $format =’json’){
// Base request url and append call method
$url = $baseURL.$method;
// CURL Parameter
if(empty($options)){
$options = array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYPEER => false
);
}
$ch = curl_init($url );
curl_setopt_array( $ch, $options );
$content = curl_exec( $ch );
curl_close( $ch );
if($format == ‘json’){
$content = json_decode($content);
}
return $content;
}
function print_job_record($job, $index){
echo ‘
Interested in this position?
‘;
echo ‘
echo $job->SerialId;
echo ‘”]
‘;
}
function print_jobs_container(){
echo “
We have found some open positions that matches your criteria!
“;
echo ‘
}
function print_jobs_container_tail() {
echo ‘
‘;
}
function apology_message() {
return “
Sorry, we couldn’t find any jobs that match your criteria, please submit your resume or contact us directly and we will reach out to you as soon as something comes available in your area.
” ;
}
if(isset($_POST[‘title’]) or isset($_POST[‘city’])){
$jobs = get_jobs(“http://fulcrum.irecruita.com/api/RequirementsAPI/Accepting”, “?keyword=”.$_POST[‘title’].”&location=”.$_POST[‘city’]) or die(apology_message());
$index = 0;
print_jobs_container();
foreach($jobs as $job){
print_job_record($job, $index);
$index++;
}
print_jobs_container_tail();
}
}
catch (Exception $e) {
echo ‘Caught exception: ‘, $e->getMessage(), “\n”;
}
[/insert_php]