kevinohashi / php-riot-api

PHP Wrapper for Riot Games API
MIT License
75 stars 40 forks source link

Special Characters in Summoner Name not working #51

Open StreakyCat opened 9 years ago

StreakyCat commented 9 years ago

Using the getSummonerId with summoner names that contain special characters (á,é,î,ô,ý...) results in NOT FOUND. A fix would be:

$query = "Summoner name with special chars á,é,î,ô,ý" ; $query = utf8_decode($query) ;

Now you can safely pass your $query to getSummonerId($query):

function getSummonerId($query)
{
    global $api;

    try 
    {
        $r = $api->getSummonerId($sum_name);
        return json2array($r);
    } 
    catch(Exception $e) 
    {
        echo "Error: " . $e->getMessage();
        return null;
    };
}

Inside your php-riot-api.php you have to modify $call inside function getSummonerByName($name):

public function getSummonerByName($name)
{   
    //OLD $call = 'summoner/by-name/' .  rawurlencode($name);
    $call = 'summoner/by-name/' . rawurlencode(utf8_encode($name));

    //add API URL to the call
    $call = self::API_URL_1_4 . $call;

    return $this->request($call);
}