/** * @param array $filters * * @return JobCollection * @throws Exception\CareerjetException */ public function search(array $filters = []) : JobCollection { $collection = new JobCollection(); $search = ['affid' => $this->affiliateId]; if (isset($filters['keywords'])) { // empty allowed $search['keywords'] = $filters['keywords']; } if (isset($filters['location'])) { // empty allowed $search['location'] = $filters['location']; } if (isset($filters['limit'])) { // max 99 $search['pagesize'] = $filters['limit']; } $search['page'] = isset($filters['offset']) ? $filters['offset'] : 1; // starts on 1 $result = $this->api->search($search); foreach ($result->jobs as $job) { $collection->add(JobBuilder::fromApi($job, $this->country)); } return $collection; }
$results = wp_cache_get('jobs-careerjet-' . jobify_string($args), 'jobify'); if (false === $results) { // Query the Careerjet PHP API $careerjet = new Careerjet_API($careerjet_locale); $params = array('page' => 1, 'affid' => $careerjet_api_key); $params['keywords'] = !empty($args['keyword']) ? $args['keyword'] : ''; // Location if (!empty($args['lat']) && !empty($args['lng'])) { $location = jobify_get_location($args['lat'] . ',' . $args['lng']); if (count($location) > 0) { $params['location'] = $location[3]; } } elseif (!empty($args['location'])) { $params['location'] = $args['location']; } $results = $careerjet->search($params); if (!$results->type == 'JOBS') { // API error $jobs[] = array('error' => __('<b>Careerjet API Error:</b> ', 'jobify') . ' Invalid result type: ' . $results->type); } else { // Save results to cache wp_cache_set('jobs-careerjet-' . jobify_string($args), $results, 'jobify', 43200); // Half a day if (!empty($results->jobs) && count($results->jobs) > 0) { foreach ($results->jobs as $key => $obj) { // Add job to array $jobs[] = array('portal' => 'careerjet', 'title' => !empty($obj->title) ? $obj->title : false, 'company' => !empty($obj->company) ? $obj->company : false, 'desc' => !empty($obj->description) ? $obj->description : false, 'app_url' => !empty($obj->url) ? $obj->url : false, 'date' => !empty($obj->date) ? $obj->date : false, 'location' => !empty($obj->locations) ? $obj->locations : false, 'custom' => array()); } } } }
<input type="submit" value="Search" /> </form></div> <?php if (isset($_GET['search']) && isset($_GET['location'])) { $search = $_GET['search']; $location = $_GET['location']; if (!empty($search) && !empty($location)) { /*~~~~~~~~~~~~~~~~~~~~~~Safe Zone~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ $client = new Indeed(""); $params = array("q" => $search, "l" => $location, "limit" => 25, "sort" => 'date', "highlight" => 1, "userip" => $_SERVER['REMOTE_ADDR'], "useragent" => $_SERVER['HTTP_USER_AGENT']); //"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2)" $results = $client->search($params); $cjapi = new Careerjet_API('en_GB'); $page = 1; # Or from parameters. $result = $cjapi->search(array('keywords' => $search, 'location' => $location, 'pagesize' => 90)); $page_num = 1; $srchApi = new SimplyHired_API(); $srchApi->set_query($search); $srchApi->set_location($location); $srchApi->set_pagenum($page_num); $result_sh = $srchApi->search_sh(); print 'Key Word : ' . ucwords($search) . "<br />"; print 'Location : ' . ucwords($location) . "<br />"; print 'Total Indeeed Jobs : ' . $results['totalResults'] . "<br />"; $in_total = $results['totalResults']; if (isset($result->hits)) { echo "Total CareerJet Jobs : " . $result->hits . "<br/>"; $cj_total = $result->hits; } else { $cj_total = 0;