How do I detect a cellular carrier dynamically through php/ajax/javascript?

rcpilotp51 picture rcpilotp51 · Apr 8, 2013 · Viewed 12.4k times · Source

I'm asking this because I've been on SO most of the day, and can’t seem to get/find an answer.

This is what I'm trying to do (without using a paid gateway):

-First of all I'm setting up a database with various info and dates.

-Using a cron I will be running a script to send out that various information (user supplied) to the user on that date via an email to SMS PHP script.

-To avoid maintaining an accurate cellular carrier list. I would like to somehow ping the number and return the carrier and the appropriate "@carrier-email-extension" to send out the message. (I don't want to ask the user during registration; to streamline registration - as not to be a PIA and get more users) - I currently have a dropdown with about 50 carriers listed (I know I may have forgotten or accidentally left out some), but I don't want to have to maintain the list. I would like to delete this part of the form. Ideally, I would like to check the number via ajax/javascript as it is entered and send the carrier info to MYSQL during submission.

-The user already agrees to get SMS messages/updates/texts from my service, so nothing malicious is going on. They will agree when setting up another message:

You will be sending a SMS message with the following information {listed information} to your mobile number, {mobile number} on {date}.

Any suggestions?

Answer

Ehtesham Haque picture Ehtesham Haque · Apr 8, 2013

Its two step Process.

  1. Find the Country Code of Mobile.. You can use Google API for that... Google provides that for free ( Google: libphonenumber - Google's phone number handling library )

  2. Network Code list is available on Wikipedia... For each country you have to implement that by picking the first few digits country code. ( Google: Mobile country code - Wikipedia )

You will find the network Code List for each country you will see operator name and MC /C MNC list. When you figured out country code of a country from a mobile number, Each carier has a unique MCC MNC . Then for each country you have to program a look up table; Pick the first 3 digit of of mobile number and assign him the network code... Do this exercise for your country operators you will figure it out.

Since i implemented it for a text API that is why i can tell you this.. Its lot of hard work. Good Luck!