Create a job searching page in PHP with Indeed APIs
Tips & Tricks 24-Sep-2016

Create a job searching page in PHP with Indeed APIs

We have created a job searching page on Coding helptech. where you can search jobs and its powered by Indeed APIs and PHP. Today I am publishing that code and page with my readers so you can easily create job searching and you can earn from there affiliation.

Account creation and integration:

Step 1. Create your publisher account click here and you will get your publisher id.

XML Job Search Feed Indeed Publisher

Step 2. Coding

Below code show you list of 10 jobs available on your given data.

<?php
require 'indeed.php'; // indeed library
$client = new Indeed("Your-Indeed-Publisher-ID");


    $params = array(
        "v" => "2",     // API Version
        "q" => "PHP",  //Job Title
        "l" => "Pakistan", // Country Name default 'United States'
        "co" => "PK",      // Country Code defauld US
        "userip" => $_SERVER['REMOTE_ADDR'], // Your IP Address
        "useragent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2)"    // user agent
    );
    $results = $client->search($params);   // API Call for results

    if($results['totalResults'] <=0)
    {
        echo "<h3>Nothing Found!!</h3>";
    }
    else
    {
        echo "<h3><b>PHP jobs in Pakistan</b></h3><br>";
    }
    echo "<table border=1>
    <tr>
        <th>Date</th>
        <th>Title</th>
        <th>Location</th>
        <th>Description</th>
    <tr>";
    for($i=0;$i<count($results['results']);$i++)
    {
        echo "
        <tr>
            <td>".$results['results'][$i]['date']."</td>
            <td><a href='?jdetails=".$results['results'][$i]['jobkey']."' target='_blank'>".$results['results'][$i]['jobtitle']."</a></td>
            <td>".$results['results'][$i]['formattedLocation'].", ".$results['results'][$i]['country']."</td>
            <td>".$results['results'][$i]['snippet']."</td>
        </tr>";
    }
    echo "</table>";
?>

This code get PHP jobs in Pakistan and show you 10 available records included indeed.php file attached in download code.

How to view a job:

This code will do that work for you.

<?php
require 'indeed.php';  // indeed library
$client = new Indeed("Your-Indeed-Publisher-ID");

if(isset($_GET['jdetails']))// Job Details
{
    $key = $_GET['jdetails'];

    $params = array("jobkeys" => array($key),);
    $result = $client->jobs($params);
                            
    $job_title = $result['results'][0]['jobtitle'];
    $job_location = $result['results'][0]['city'];
    echo "<table border=1>
    <tr>
        <th>Posted</th>
        <th>Title</th>
        <th>City</th>
        <th>Description</th>
        <th>Company</th>
    <tr>";
    echo "
        <tr>
            <td>".$result['results'][0]['formattedRelativeTime']."</td>
            <td>".$result['results'][0]['jobtitle']."</td>
            <td>".$result['results'][0]['city']."</td>
            <td>".$result['results'][0]['snippet']."</td>
            <td>".$result['results'][0]['company']."</td>
        </tr>";
    echo "</table>";
}
?>

Code above show details of a job by job key.

That’s it.