Пример #1
0
 /**
  * @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;
 }
Пример #2
0
 */
require_once JOBIFY_ROOT . 'src' . DIRECTORY_SEPARATOR . 'Careerjet_API.php';
jobify_addAPI(array('key' => 'careerjet', 'title' => __('Careerjet', 'jobify'), 'logo' => plugins_url('img/careerjet.jpg', JOBIFY_PLUGIN), 'requirements' => array('geolocation' => __('Supports geolocation if enabled.', 'jobify')), 'getJobs' => function ($args) {
    // Create the returned jobs array
    $jobs = array();
    // Get Jobify settings
    $settings = jobify_settings();
    // Set the Careerjet affiliate ID
    $careerjet_api_key = !empty($settings['careerjet_api_key']) ? $settings['careerjet_api_key'] : 'b4a44bbbcaa7fe6bfd6039d1e864294e';
    // Set the Careerjet locale
    $careerjet_locale = !empty($args['careerjet_locale']) ? $args['careerjet_locale'] : 'en_US';
    // Check cache for results
    $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);
<form action="clone_up.php" method="get" enctype="multipart/form-data">
Search: <input type="text" name="search" />
  	<input type="text" name="location"  />
        <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/>";