to retrieve data using php. The idea is that javascript can't and isn't safe to use so the alternative
is to use a proxy server script to do the work.
This first line of code is given to make the connection
Code: Select all
//holds the remote server address and parameters
$serverAddress = "http://www.random.org/cgi-bin/randum";
$serverParams = "num=" . $num . //how many random numbers to genrate
"&min=" . $min . //the min number to generate
"&max=" . $max; // max number to generate
//connecting to a foreign server and get contents
$randomNumber = file_get_contents($serverAddress . '?' . $serverParams);
Code: Select all
//use if file_get_contents() fails
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, "$serverAddress . '?' . $serverParams");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$randomNumber = curl_exec($ch);
curl_close($ch);
// display file
echo $randomNumber;Can anyone suggest how I might resolve this issue?
Kevin