Skip to main content

PHP - how to find out your phone carrier

Finding the Carrier of a Cell Phone Number in PHP



By: George Huger

June 20, 2011

Often web apps need to send SMS messages to their users (for example: balance alerts, reminders, notifications). To send these text messages from within your app, you basically have 2 options:

1) Pay Twilio and Tropo for the use of their APIs, for roughly a penny per message.

2) Send an email directly to their carrier’s mail-to-SMS gateway – a free service most carriers provide, which will translate your email into an SMS sent to their subscribers’ phone

Twilio and Tropo are about as easy as it gets to integrate (REST-like APIs that return JSON/POX), but you pay for every single message and that can add up quickly. So #2 (mail-to-SMS gateways) starts to look pretty good.

But there’s some problems with mail-to-SMS gateways:

1) Each carrier has their own format. For example, T-Mobile’s gateway is number@tmomail.net (for the US), AT&T’s is number@txt.att.net (for most of their customers), and Verizon is number@vtext.net (unless you used to be with Alltel – then its number@message.alltel.com). A big list of mail-to-SMS-gateways is available on Wikipedia.

Bonus:some carriers want the international code prepended (the 1 in front of the number, for the US), some carriers don’t. (e.g., T-Mobile does, AT&T doesn’t)

2) Some carriers require authentication (Sprint) or don’t have a mail-to-SMS gateway at all (Google Voice).

3) If the user ports their number to a different carrier you’ll have to detect it and react accordingly.

So you’ll have to figure out what carrier they’re using in order to direct the email and meet whatever requirements – which usually means asking the user to choose their carrier from a list.

There is a better way! What if we could detect the carrier automatically?

It turns out you can. The lovely folks at CloudVox made an API that does exactly that – you give it a phone number, and it tells you the carrier and if its a cell-phone or landline. Its 100% free, with no API keys/credentials required.

Its hosted at digits.cloudvox.com, along with example calls/responses (full docs are here). It speaks JSON over HTTP.

This gives us a much better user experience:

1) User inputs their number, no carrier dropdown needed

2) We use CloudVox’s API to determine their carrier

3) Try to send them an SMS, and have them confirm ownership in the normal way (i.e., enter a confirmation code)

This will cover most people, and is free outside of the development time. If there was an error (i.e., we couldn’t find the number with CloudVox’s API, or we did but the carrier doesn’t support mail-to-SMS), we can fall back to Twilio or Tropo. We’re still paying a few cents here and there, but the default case is free.

Here’s some example code in PHP, for querying CloudVox’s API:

Source : http://illuminatikarate.com/blog/finding-the-carrier-of-a-cell-phone-number-in-php/

Comments

Popular posts from this blog

Next Class @sisindotek : I.T Project Management

Follow our next IT Professional Class @sisindotek CON-01 - Project Management Methodologies With Microsoft Project 2010 Biaya : Rp 4.600.000 (Non Residential) | Rp 5.750.000 (Residential) Durasi : 4 Hari, Start : 13,20,27 Feb 2012, 2 April 2012, Lokasi : Hotel Bintang Bandung Fasilitas Standar : Penginapan** Kamar Hotel per Peserta, Breakfast** + 2x coffee break + Lunch **, Buku Panduan, Training Kit , Laptop/ peserta , Software Pendukung, Sertifikat , Flash Disk, Souvenir Waktu Training : 09.00 - 17.00 WIB (diselingi 2x coffee break + Lunch) Note :(**) Hanya untuk Paket Residential INHOUSE TRAINING : Rp 700.000/ Peserta/ Hari (Minimal 3 Peserta), Diskon 10% untuk peserta group > 5 Informas dan ketentuani Inhouse Training hubungi : 022-71242266 atau 0812.8733.1966 , info@sisindotek,com SISINDOTEK - I.T Training & Solution Provider Jl. Sukasenang VI - 6 B Cikutra Bandung Jawa Barat 40124 Tel. 022-71242266, 0812.8733.1966 Email : info@sisindotek.com , YM. sisindotek www.sisindotek...

blackpink On Spotify | www.viestaspa.xyz outcall massage 24 hours in bandung jakarta surabaya yogya 6283804100031 whatsapp

Pencarian Blackpink On Spotify Ditemukan Dengan Beberapa Hasil Sesuai Kata Kunci Blackpink Dan Plus Beberapa Hasil Lainnya Untuk Blackpink On Spotify , Silahkan Akses Www.viestaspa.xyz Outcall Massage 24 Hours In Bandung Jakarta Surabaya Yogya 6283804100031 Whatsapp Untuk Halaman Yang Ditemukan Perihal Blackpink Dan Sumber Informasi Bukan Hoax Untuk Blackpink Agar Mendapat Penjelasan Detail Terkait Blackpink On Spotify Yang Trending Per Hari Ini Dan Dapat Membantu Anda Mendapatkan Informasi Menyeluruh Terkait Pencarian Blackpink, Terima Kasih . Informasi Lainnya Dari Contact.my.id Yang Mungkin Anda Butuhkan Dan Bermanfaat Sambil Membaca Ulasan Berita Blackpink On Spotify Tersebut Antara Lain : Www.viestaspa.xyz Outcall Massage 24 Hours In Bandung Jakarta Surabaya Yogya 6283804100031 Whatsapp | Informasi WATO.xyz Click To Chat Untuk Plugin Whatsapp Chat Di Web Anda - How To Create Link Using Www.wato.xyz Very Simple

blackpink Announces New Single And Album - Paper | www.viestaspa.xyz outcall massage 24 hours in bandung jakarta surabaya yogya 6283804100031 whatsapp

Pencarian Blackpink Announces New Single And Album - Paper Ditemukan Dengan Beberapa Hasil Sesuai Kata Kunci Blackpink New Single Dan Plus Beberapa Hasil Lainnya Untuk Blackpink Announces New Single And Album - Paper , Silahkan Akses Www.viestaspa.xyz Outcall Massage 24 Hours In Bandung Jakarta Surabaya Yogya 6283804100031 Whatsapp Untuk Halaman Yang Ditemukan Perihal Blackpink New Single Dan Sumber Informasi Bukan Hoax Untuk Blackpink New Single Agar Mendapat Penjelasan Detail Terkait Blackpink Announces New Single And Album - Paper Yang Trending Per Hari Ini Dan Dapat Membantu Anda Mendapatkan Informasi Menyeluruh Terkait Pencarian Blackpink New Single, Terima Kasih . Informasi Lainnya Dari Contact.my.id Yang Mungkin Anda Butuhkan Dan Bermanfaat Sambil Membaca Ulasan Berita Blackpink Announces New Single And Album - Paper Tersebut Antara Lain : Www.viestaspa.xyz Outcall Massage 24 Hours In Bandung Jakarta Surabaya Yogya 6283804100031 Whatsapp | Informasi WATO.xyz Click To Chat...