Bulk API call

  • Ads

Bulk API call

Postby dan » Thu Apr 15, 2010 11:29 am

I need to check a couple hundred ip's around once a week. I wrote a script that just does one api call for each ip but I don't want to hammer the servers. Is there any bulk api call I can make that's easier on the servers?

Doing file_get_contents("http://www.ipinfodb.com/ip_query.php?ip=$ip&output=xml&timezone=false"); 500 times just seems to inefficient.
dan
 
Posts: 2
Joined: Thu Apr 15, 2010 11:27 am

Re: Bulk API call

Postby marchost » Thu Apr 15, 2010 11:38 am

Hi, using ip_query2.php you can do up to 25 lookup.

http://ipinfodb.com/ip_query2.php?ip=74.125.45.100,206.190.60.37&timezone=false (http://ipinfodb.com/ip_location_api.php)

The PHP class available will do 25 lookup at a time automatically...

Marc
marchost
Site Admin
 
Posts: 373
Joined: Wed Apr 08, 2009 9:55 pm

Re: Bulk API call

Postby dan » Thu Apr 15, 2010 11:53 am

So using that class if I have a loop that does a bunch of $geolocation->setIP("66.135.205.14")

It will automatically group 25 ips per call when I do $geolocation->getGeoLocation(); ?
dan
 
Posts: 2
Joined: Thu Apr 15, 2010 11:27 am

Re: Bulk API call

Postby marchost » Thu Apr 15, 2010 12:00 pm

Yes, you can run a loop for all your IP but they will not be grouped by 25 in the output.

Let say you have 120 IP, the class will do 5 calls and the output will be an array from 0-119 (maybe 1-120...)

you simply have to do something like

foreach($ips as $ip){
$geolocation->setIP($ip)
}
marchost
Site Admin
 
Posts: 373
Joined: Wed Apr 08, 2009 9:55 pm


Return to IP geolocation API related



Who is online

Users browsing this forum: MSN [Bot] and 1 guest

cron