Ejemplo n.º 1
0
<?php

spl_autoload_register(function ($class_name) {
    include "../inc/" . $class_name . '.php';
});
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : PinnacleClient::SOCCER_ID;
$fixture = new Fixture($id);
$pinnacle_client = new PinnacleClient();
$json = $pinnacle_client->query("https://api.pinnaclesports.com/v1/fixtures?sportid=" . $id . "&since=" . $fixture->get('last'));
$fixture->set('last', $json->last);
foreach ($json->league as $l) {
    $league = new League($l->id);
    $league->set('sportId', $id);
    foreach ($l->events as $e) {
        $event = new Event($e->id);
        $event->set('leagueId', $l->id);
        $event->set('starts', $e->starts);
        $event->set('home', $e->home);
        $event->set('away', $e->away);
        $event->set('rotNum', $e->rotNum);
        if (isset($e->homePitcher)) {
            $event->set('homePitcher', $e->homePitcher);
        }
        if (isset($e->awayPitcher)) {
            $event->set('awayPitcher', $e->awayPitcher);
        }
    }
}