Search code examples
phpgetresponse

Does something like HTTP_GET_RESPONSE exist?


I was curious about getting the result of this http://api.hostip.info/country.php?ip=141.100.10.49 (Result = DE) into a variable i can use to write into my DB (last thing is easy for me but i am curious about getting an answer how to do the first thing. beneath the snippet i had in my mind :-)

    <?php
    $in = HTTP_GET_RESPONSE('http://api.hostip.info/country.php?ip=141.100.10.49');
    echo $in;
    /*write to DB*/
    ?>

thanks for the help in advance!

P.S.: I don't know much about java/python/C(+/++/#)

P.P.S.: http://kater.selfhost.me/stats/test.php that's the result :-(


Solution

  • If your system is configured appropriately you can use:

     <?php
    $in = file_get_contents('http://api.hostip.info/country.php?ip=141.100.10.49');
    echo $in;
    /*write to DB*/
    ?>
    

    Just make sure you have allow_url_fopen set in php.ini