NationStates Jolt Archive


PHP read Nation or region info

Saint-Malo
04-04-2005, 12:58
Hello,
i've started a PHP script for getting info for all info from my region, and load it in a Database.

But when i try to get info from the url :
file_get_contents('http://www.nationstates.net/cgi-bin/index.cgi/target=display_nation/nation=THe_NATION');

whtih my brwser it is OK, but from PHP Script i get NOTHING .

Any idea ,

Best Regards
Juxtapositions
04-04-2005, 16:33
Take the data below, save it to a filename "test.php". Put it in the directory your webserver serves up pages from. Then using your browser go to http://localhost/test.php
You should see a page printed out or an error if there is a problem accessing NationStates. If you see nothing check your webserver and php configuration on your machine.


<html>
<body>
<?php
$filestuff= file_get_contents("http://www.nationstates.net/cgi-bin/index.cgi/page=display_nation/nation=Myrth");
if($filestuff == FALSE){
printf("Bad kitty, the server must be all farked up. No data for the nation Myrth (He's probably deated again)");
exit;
}
else
printf("%s", $filestuff);
?>
</body>
</html>
Jjuulliiaann
04-04-2005, 21:12
Hello,
i've started a PHP script for getting info for all info from my region, and load it in a Database.

But when i try to get info from the url :
file_get_contents('http://www.nationstates.net/cgi-bin/index.cgi/target=display_nation/nation=THe_NATION');

whtih my brwser it is OK, but from PHP Script i get NOTHING .

Any idea ,

Best RegardsCould I get a copy of that script? Please?
It's OK if you don't want to share.