Page 1 of 1

Data From External Website

Posted: Sun Mar 15, 2009 10:36 am
by Rahvasaadik
Hi. I'm having an issue with getting an integer from an external website

Code: Select all

http://www.random.org/integers/?num=1&m ... in&rnd=new
Since that pages php script outputs only one thing into the source (the integer) i figured i could somehow make my php script goto that page and save everything in the source (or on the page for all that matters) into a predefined variable in a function.

Note that the page mentioned above generates a random number from atmospheric noise and I really need a total random number generator for my page. No pseudo-random stuff.

Re: Data From External Website

Posted: Sun Mar 15, 2009 3:08 pm
by Benjamin
What is your code?

Re: Data From External Website

Posted: Sun Mar 15, 2009 3:17 pm
by socket1
This code sets the variable, $Random, to whatever the page returns:

Code: Select all

<?php
$URL = "http://www.random.org/integers/?num=1&min=100000000&max=999999999&col=1&base=10&format=plain&rnd=new";
$handle = fopen($URL, 'r');
$Random = stream_get_contents($handle);
fclose($handle);
echo $Random;
?>

Re: Data From External Website

Posted: Mon Mar 16, 2009 2:26 am
by Rahvasaadik
astions wrote:What is your code?
The problem was, that I didn't even have code, since I had no idea how to go about it.

Thank you socket1! It works like magic (makes future reference of the functions used in the script). :)