prospect Posted March 27, 2007 Share Posted March 27, 2007 Hey guys , just need a little help I want to send a search string to showmyip.com and get the results back .. anyone ot similar experince? Quote Link to comment https://forums.phpfreaks.com/topic/44461-ip-localization/ Share on other sites More sharing options...
monk.e.boy Posted March 27, 2007 Share Posted March 27, 2007 Try http://uk.php.net/curl set it to return the HTML as a string. Then use it to browse to http://www.site.com?query=123, then look at the HTML returned and do some regex to grab the data you want. monk.e.boy Quote Link to comment https://forums.phpfreaks.com/topic/44461-ip-localization/#findComment-215923 Share on other sites More sharing options...
DeathStar Posted March 27, 2007 Share Posted March 27, 2007 If it is "IP Localization": Try searching for ranges.. Quote Link to comment https://forums.phpfreaks.com/topic/44461-ip-localization/#findComment-215927 Share on other sites More sharing options...
prospect Posted March 27, 2007 Author Share Posted March 27, 2007 Thanks guys , but don't think I explained myself good I did try the IP range but thats too much and don't have that of a big database so I jsut wanted to use showmyip.com as webservice to check the ip I send and recive back the country name $ip=$_SERVER['REMOTE_ADDR']; $url='http://www.showmyip.com/?ip='; Its just how to actully send it automaticlly when the user logs in the page and then direct him upon finding his country Quote Link to comment https://forums.phpfreaks.com/topic/44461-ip-localization/#findComment-215931 Share on other sites More sharing options...
monk.e.boy Posted March 27, 2007 Share Posted March 27, 2007 CURL!!!!! monk.e.boy Quote Link to comment https://forums.phpfreaks.com/topic/44461-ip-localization/#findComment-215936 Share on other sites More sharing options...
prospect Posted March 27, 2007 Author Share Posted March 27, 2007 Okai gotcha <?php $ip = addslashes($_SERVER['REMOTE_ADDR']); // initialise the session, this time with no URL $ch = curl_init(); // Setting the URL including the IP curl_setopt($ch, CURLOPT_URL, "http://www.showmyip.com/?ip=$ip"); // Return the output from the cURL session rather than displaying in the browser. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Executting the session, returning the results to $country, and close. $Country = curl_exec($ch); curl_close($ch); print "country of $ip: $Country"; ?> doesn't return anything Quote Link to comment https://forums.phpfreaks.com/topic/44461-ip-localization/#findComment-215945 Share on other sites More sharing options...
monk.e.boy Posted March 27, 2007 Share Posted March 27, 2007 Should work, maybe you have set the options in the wrong order? $Country, should be $html as CURL will return the raw html of the page. But other than that it should work. You will need to output the HTML and take a look at it in regex buddy to see how to snip out the country code. monk.e.boy Quote Link to comment https://forums.phpfreaks.com/topic/44461-ip-localization/#findComment-215957 Share on other sites More sharing options...
prospect Posted March 27, 2007 Author Share Posted March 27, 2007 okai keep getting this error <?php $ip = addslashes($_SERVER['REMOTE_ADDR']); // initialise the session, this time with no URL $ch = curl_init(); // Setting the URL including the IP curl_setopt($ch, CURLOPT_URL, "http://www.showmyip.com/?ip=$ip"); // Return the output from the cURL session rather than displaying in the browser. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Executting the session, returning the results to $country, and close. $html = curl_exec($ch); curl_close($ch); print "$html"; ?> Fatal error: Call to undefined function: curl_init() in /home/www/digitall/func_test.php on line 7 Quote Link to comment https://forums.phpfreaks.com/topic/44461-ip-localization/#findComment-215962 Share on other sites More sharing options...
dsaba Posted March 27, 2007 Share Posted March 27, 2007 call php_info(); make sure you have curl library installed, if you want to use curl functions Quote Link to comment https://forums.phpfreaks.com/topic/44461-ip-localization/#findComment-215966 Share on other sites More sharing options...
monk.e.boy Posted March 27, 2007 Share Posted March 27, 2007 If you don't have cURL, then use fopen( 'http://my.web.site.com/?id=99' ); monk.e.boy Quote Link to comment https://forums.phpfreaks.com/topic/44461-ip-localization/#findComment-215969 Share on other sites More sharing options...
prospect Posted March 27, 2007 Author Share Posted March 27, 2007 hey guys cheers for all the input Seems like I don't have cURL installed so I tried MB's idea using fopen <? $ip = addslashes($_SERVER['REMOTE_ADDR']); $data = fopen("http://www.showmyip.com/?ip=$ip", "r"); print' $data'; ?> that returns only $data seems nothing is caputered but when i try http://www.showmyip.com/?ip=xxx.xxx.xxx.xxx it returns all the details so the format is right again thanks Quote Link to comment https://forums.phpfreaks.com/topic/44461-ip-localization/#findComment-215975 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.