hristonev / sportmonks-client-bundle

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

How to integrate API #6

Open hirenbhuva1993 opened 6 years ago

hirenbhuva1993 commented 6 years ago

I have downloaded the API.

But, I'm not able to create how-to call and configure this API.

I don't know how can I use FunctionalTest.php.

So please guide me for the same. Like what is the API call and request URL.

hristonev commented 6 years ago

All information is in Readme.md file. Just replace "open sesame" with your token and you will be able to make API calls. Tests are working with php-unit.

QES commented 5 years ago

Are there any other examples the one you provide works perfectly but wondered if there were a few more examples people could share as examples of how this works...

hristonev commented 5 years ago
/**
 * @param string $code
 * @param \DateTime $start
 * @param \DateTime $end
 * @return array
 * @throws \SportMonks\API\Exceptions\MissingParameterException
 */
private function getFixtureByDate($code, $start, $end = null)
{
    $rateLimit = null;
    $cache = $this->getData($code);
    if(is_null($cache)) {
        $include = [
            'query' => [
                'include' => 'substitutions,goals,cards,corners,stats,comments,tvstations,referee,odds,group' // up to 10
            ]
        ];
        $data = [];
        do {
            if(is_null($end)){
                $data = array_merge($data, $this->api->fixtures()->date()->day($start, $include));
            }else{
                $data = array_merge($data, $this->api->fixtures()->between()->period($start, $end, null, $include));
            }
        } while ($this->api->fixtures()->between()->NextPage($include));
    }
    $rateLimit = (int)$this->api->getRateLimitRemaining();
    return [
        $rateLimit,
        $data
    ];
}

Fixtures by date and period.

QES commented 5 years ago

Thanks - useful.