Exemple #1
0
//tell me stuff
$app = new \Slim\Slim();
$app->get('/home', function () {
});
//so far nothing for home
$app->get('/selection/:job', function ($job) {
    $client = new Indeed("4779755742469402");
    $params = array("q" => $job, "l" => $location, "userip" => $_SERVER['REMOTE_ADDR'], "useragent" => $_SERVER['HTTP_USER_AGENT'], "limit" => "25");
    $results = $client->search($params);
    echo json_encode($results);
});
$app->get('/selection/:job/:location', function ($job, $location) {
    $client = new Indeed("4779755742469402");
    $params = array("q" => $job, "l" => $location, "userip" => $_SERVER['REMOTE_ADDR'], "useragent" => $_SERVER['HTTP_USER_AGENT'], "limit" => "25");
    $results = $client->search($params);
    echo json_encode($results);
});
$app->get('/selection/:job/:location/:page', function ($job, $location, $page) {
    $client = new Indeed("4779755742469402");
    $params = array("q" => $job, "l" => $location, "start" => $page * 25, "userip" => $_SERVER['REMOTE_ADDR'], "useragent" => $_SERVER['HTTP_USER_AGENT'], "limit" => "25");
    $results = $client->search($params);
    echo json_encode($results);
});
$app->post('/contact', function () {
    //send message in content
    $message = $_POST['name'];
    $message .= $_POST['phone'];
    $message .= $_POST['message'];
    echo $message;
});
$app->run();
Exemple #2
0
 public function indeed($query, $city)
 {
     $loc = $city;
     $result = array();
     // to call Indeed API
     require_once getcwd() . '/indeed/indeed.php';
     // Indeed publisher number 5595740829812660
     $client = new Indeed("5595740829812660");
     // parameters pass to indeed API
     $params = array("q" => $query, "l" => $loc, "limit" => 25, "userip" => '131.94.128.231', "useragent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:12.0) Gecko/20100101 Firefox/12.0");
     // search results from indeed.com
     $results = $client->search($params);
     // get array of jobs
     $result = $this->xmlToArray($results);
     // convert snippets to skills
     $snippets = array();
     $j = 0;
     // if there are results from indeed.com API
     if ($result['totalresults'] > 0) {
         if ($result['totalresults'] == 1) {
             //print_r($result);die;
             $snippets[$j] = strtolower($result['results']['result']['snippet']);
             $snippets[$j] = utf8_decode($snippets[$j]);
             //$snippets[$j] = iconv(mb_detect_encoding($snippets[$j], mb_detect_order(), true), "ISO-8859-1//IGNORE", $snippets[$j]);
             $result['results']['result']['snippet'] = '';
         } else {
             for ($i = 0; $i < count($result['results']['result']); $i++, $j++) {
                 $snippets[$j] = strtolower($result['results']['result'][$i]['snippet']);
                 $snippets[$j] = utf8_decode($snippets[$j]);
                 // $snippets[$j] = iconv(mb_detect_encoding($snippets[$j], mb_detect_order(), true), "ISO-8859-1//IGNORE", $snippets[$j]);
                 $result['results']['result'][$i]['snippet'] = '';
             }
         }
         if ($result['totalresults'] == 1) {
             // put back into results snippet as skill words
             // check each snipped for skills
             $cur_snippet = $snippets[0];
             $cur_snippet = str_replace(array('.', '/', ',', '.'), ' ', $cur_snippet);
             $cur_snippet_words = explode(' ', $cur_snippet);
             // split into words
             foreach ($cur_snippet_words as $snippet_word) {
                 // check database to see if current word is a skill
                 $skill = Skillset::model()->find("LOWER(name)=:name", array(":name" => $snippet_word));
                 if ($skill) {
                     $cur_skills = strtolower($result['results']['result']['snippet']);
                     if (!strstr($cur_skills, $snippet_word)) {
                         $result['results']['result']['snippet'] .= ucfirst($snippet_word) . ' ';
                     }
                 }
             }
         } else {
             // put back into results snippet as skill words
             for ($i = 0; $i < count($result['results']['result']); $i++) {
                 // check each snipped for skills
                 $cur_snippet = $snippets[$i];
                 $cur_snippet = str_replace(array('.', '/', ',', '.'), ' ', $cur_snippet);
                 $cur_snippet_words = explode(' ', $cur_snippet);
                 // split into words
                 foreach ($cur_snippet_words as $snippet_word) {
                     // check database to see if current word is a skill
                     $skill = Skillset::model()->find("LOWER(name)=:name", array(":name" => $snippet_word));
                     if ($skill) {
                         // append current word (skill) to results snippet (check duplicates)
                         $cur_skills = strtolower($result['results']['result'][$i]['snippet']);
                         if (!strstr($cur_skills, $snippet_word)) {
                             $result['results']['result'][$i]['snippet'] .= ucfirst($snippet_word) . ' ';
                         }
                     }
                 }
             }
         }
     }
     return $result;
 }