paquettg / leaguewrap

League of Legend API wrapper
MIT License
67 stars 28 forks source link

Ranked Stats problem #64

Closed leandrosandmann closed 9 years ago

leandrosandmann commented 9 years ago

Fatal error: Call to a member function seek() on a non-object in ~/paquettg/leaguewrap/src/LeagueWrap/Client.php on line 74

This is when I try to get information leagues users who do not have ranked stats. $api->league()->league($summonerId, true);

dnlbauer commented 9 years ago

it is expected that the api throws an exception if a 404 occures. This might change soon (see issue #59 )

alabama commented 9 years ago

Hey @danijoo, Hey @paquettg, just to mention the Riot-API returns different "body content" on 404 responses. In the current 'LeagueWrap\Client' on line 68-76

        $response = $this->guzzle
                         ->get($uri, ['connect_timeout' => $this->timeout,
                                      'exceptions' => false]);

        $body = $response->getBody();
        $code = $response->getStatusCode();
        $body->seek(0);
        $content  = $body->read($body->getSize());
        $response = new Response($content, $code);

the body variable should be an object, but if you do these requests: 1: https://euw.api.pvp.net/observer-mode/rest/consumer/getSpectatorGameInfo/EUW1/{a_summonerId_who_is_not_in_game}?api_key={your_api_key} 2: https://euw.api.pvp.net/api/lol/euw/v2.5/league/by-summoner/{a_summonerId_withouth_ranked_stats}/entry?api_key={your_api_key} You can see that in request 1: there is a body, but in request 2 there is only the status code without a body. So keep that in mind when changing the code!