i have a problem. I have made a PHP proxy to get json data from an external server using this code :
<?php
$url = $_GET['url'];
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
$data = curl_exec($ch);
curl_close($ch);
echo("<h1>".$url."</h1>");
echo (substr($data,0,-1));
?>
But i have to pass this link “http://isohunt.com/js/json.php?ihq=ubuntu&sort=age” and since i have an & in there my php script can’t properly evaluate the link. How i solve the issue?
Before passing the target URL to the script via the url GET parameter, encode it with
urlencode()(or an equivalent depending on where the target URL enters the situation).The encoding will be automatically reversed when you retrieve
$_GET['url'], leaving you with the original (desired) URL. (Kudos to Quentin for correcting me here).Hope this helps.