PHP URL parameters append return special character
Posted
by
Alexandre Lavoie
on Stack Overflow
See other posts from Stack Overflow
or by Alexandre Lavoie
Published on 2012-11-19T04:23:04Z
Indexed on
2012/11/19
5:00 UTC
Read the original article
Hit count: 261
I'm programming a function to build an URL, here it is :
public static function requestContent($p_lParameters)
{
$sParameters = "?key=TEST&format=json&jsoncallback=none";
foreach($p_lParameters as $sParameterName => $sParameterValue)
{
$sParameters .= "&$sParameterName=$sParameterValue";
}
echo "<span style='font-size: 16px;'>URL : http://api.oodle.com/api/v2/listings" . $sParameters . "</span><br />";
$aXMLData = file_get_contents("http://api.oodle.com/api/v2/listings" . $sParameters);
return json_decode($aXMLData,true);
}
And I am calling this function with this array list :
print_r() result : Array ( [region] => canada [category] => housing/sale/home )
But this is very strange I get an unexpected character (note the special character none*®*ion) :
http://api.oodle.com/api/v2/listings?key=TEST&format=json&jsoncallback=none®ion=canada&category=housing/sale/home
For information I use this header :
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<?php header('Content-Type: text/html;charset=UTF-8'); ?>
EDIT :
$sRequest = "http://api.oodle.com/api/v2/listings?key=TEST&format=json&jsoncallback=none®ion=canada&category=housing/sale/home";
echo "<span style='font-size: 16px;'>URL : " . $sRequest . "</span><br />";
return the exact URL with problem :
http://api.oodle.com/api/v2/listings?key=TEST&format=json&jsoncallback=none®ion=canada&category=housing/sale/home
Thank you for your help!
© Stack Overflow or respective owner