PHP code example of sethsharp / odds-api

1. Go to this page and download the library: Download sethsharp/odds-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/ */

    

sethsharp / odds-api example snippets


$client = new OddsClient(config('odds-api.api_key'));

$response = $client->setRegion('us')
    ->dateFormat('iso')
    ->getOddsForSport(SportsEnum::RUGBYLEAGUE_NRL);

return $response->json();

$this->app->bind(OddsClient::class, function () {
    return new OddsClient(config('odds-api.api_key'));
});

use HandlesOddsResponse;

public function __invoke(OddsClient $client): Response
{
    $response = $client->setRegion('us')
        ->getOddsForSport(SportsEnum::RUGBYLEAGUE_NRL);
        
    return $this->extractJsonFromResponse($response);
}

$this->params = [
    'api_key' => $this->apiKey,
    'regions' => config('odds-api.default_region'),
    'oddsFormat' => config('odds-api.default_odds_format')
];
bash
php artisan vendor:publish --tag="odds-api-config"