How to determine if incoming IP address is from a

2019-02-12 07:02发布

问题:

Does anybody know of a good way (free or paid) to determine if an incoming IP is from a mobile carrier?

There was a previous question on this: API to determine cell carrier?

and the answer was "use an ISP database and match names". I guess I'm hoping that in the year and a half since this question was asked somebody came up with something cleaner?

fingers crossed

回答1:

I have a mobile web site and I needed to do IP geo-location. I had a look at several IP->Location databases. One of which was MaxMind. They have a free database which provides city level accuracy, but they also have a paid for database (for a pretty reasonable fee) that gives you more detail, including what mobile carrier a mobile user is coming in on.

Go to http://www.maxmind.com and put your IP into the demo entry box (its on front page), and you'll see the detail you can get. This is the API you would need from them: http://www.maxmind.com/app/isp

Like I say, I only use the city level detail database so can't vouch for the coverage of the mobile carriers. But during my initial tests, it did always seem to return good values for the UK, Ireland, and Asian mobiles I tested.

Rgds, Kevin.



回答2:

If this is for a web site, you could examine the HTTP_USER_AGENT. Of course this can be faked.

If this is indeed for a website, please give your users the option to look at the none mobile-optimised version!



回答3:

You could use hostip. They have a constantly evolving list of IPs and where they are located.

You can get information such as physical location, country and the host name for that IP.

You could poll for data and check the host name against a list of pre defined carriers with a regular expression or something.

More info here: http://www.hostip.info/



回答4:

NetAcuity aka Digital Envoy has Carrier Targeting (feature 24) which is normally pay $ license, but I believe they have a 30-day trial program.



回答5:

This is what i use:

if (preg_match("@(android|iphone|opera mini|blackberry)@is",$_SERVER['HTTP_USER_AGENT'])) {
    $mobile = true;
} else {
    $mobile = false;
}


标签: mobile ip