Well i dont know whats wrong.
$charname = mb_convert_encoding("Bausí", "HTML-ENTITIES", "UTF-8");
$realm = "Blackrock";
$_SESSION["region"] = "eu";
$opts = array('https' => array('header' => 'Accept-Charset: UTF-8, *;q=0'));
$context = stream_context_create($opts);
$char_params = array(
'fields' => "statistics",
'locale' => "en_GB",
'apikey' => "my_api_key"
);
$char_url = "https://".$_SESSION['region'].".api.battle.net/wow/character/".str_replace("'","",$realm)."/".$charname."?".http_build_query($char_params);
if (!$json_char_o = file_get_contents($char_url, false, $context)) {
$error = error_get_last();
echo "HTTPs request failed. Error was: " . $error['message'];
}else{
echo $json_char_decoded = json_decode($json_char_o);
}
it throws me an error:
HTTP request failed. Error was: file_get_contents(https://eu.api.battle.net/wow/character/Blackrock/Bausí?fields=statistics&locale=en_GB&apikey=my_api_key): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
The response should be a json object.
If i open the link manually it works perfectly. What is wrong? :/