hristonev / sportmonks-client-bundle

Easily talk to an SportMonks API in PHP
MIT License
14 stars 7 forks source link

Fixtures are missing pagination method #4

Open Blysq opened 6 years ago

Blysq commented 6 years ago

Those API endpoints DO implement pagination as per https://www.sportmonks.com/products/soccer/docs/2.0/fixtures/18 docs. This applies to:

However when you try to paginate it you get: Fatal error: Uncaught Exception: Method nextPage does not exist SportMonks\API\Resources\FixturesBetween in path_removed/vendor/hristonev/sportmonks-client-bundle/src/SportMonks/API/Traits/Utility/InitTrait.php:37

hristonev commented 6 years ago

I'll check it next days.

kashmiry commented 5 years ago

+1 is there a fix for this yet?

kashmiry commented 5 years ago

I found a solution for this, not sure how efficient it is and compatible, until now it's working perfectly for me! First make sure you have the dev-master branch for latest changes, and check @evsar3 fork: https://github.com/evsar3/sportmonks-client-bundle I found half the solution at his fork.

I was able to get the matches in pagination, but when I added a param like (leagues) I was thrown into an eternal loop. My fix to this I had to make changes to function nextPage() to make it keep hold of params when going through a pagination, check my fork for full code log: https://github.com/kashmiry/sportmonks-client-bundle

To call the matches do it like this:

$from_date = new datetime($start_date);
$to_date = new datetime($end_date);

$matches_options = [
    'query' => [
        'leagues' => $league_id
    ]
];

$matches = [];
do {
    $matches = array_merge($matches, $client->fixtures()->between()->period($from_date, $to_date, null, $matches_options));
} while ($api->fixtures()->nextPage($matches_options));