PHP code example of sharpapi / laravel-job-positions-api

1. Go to this page and download the library: Download sharpapi/laravel-job-positions-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sharpapi / laravel-job-positions-api example snippets




namespace App\Http\Controllers;

use GuzzleHttp\Exception\GuzzleException;
use SharpAPI\JobPositionsApi\JobPositionsApiService;

class JobPositionsController extends Controller
{
    protected JobPositionsApiService $jobPositionsService;

    public function __construct(JobPositionsApiService $jobPositionsService)
    {
        $this->jobPositionsService = $jobPositionsService;
    }

    /**
     * @throws GuzzleException
     */
    public function searchJobPositions(string $query)
    {
        $results = $this->jobPositionsService->searchJobPositions($query);
        
        return response()->json($results);
    }

    /**
     * @throws GuzzleException
     */
    public function getJobPositionDetails(string $positionId)
    {
        $position = $this->jobPositionsService->getJobPositionById($positionId);
        
        return response()->json($position);
    }
    
}

use GuzzleHttp\Exception\ClientException;

try {
    $positions = $this->jobPositionsService->searchJobPositions('developer');
} catch (ClientException $e) {
    echo $e->getMessage();
}
bash
php artisan vendor:publish --tag=sharpapi-job-positions-api
bash
SHARP_API_KEY=your_api_key_here
SHARP_API_BASE_URL=https://sharpapi.com/api/v1