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

Cara Setting Blogspot ke dot.tk

Cara Setting blogspot ke domain dot.tk (free domain) , Thank to mas Difa Dikutip dari blog mas difa Buat teman - teman yang belum mengerti dan ingin tahu silahkan simak artikel ini sampai akhir. Bagaimana cara setting domain blogspot ke dot TK. Perlu diketahui dot TK adalah sebuah layanan yang memberikan jasa untuk domain yang gratis atau free. Setelah sedikit review tentang dot tk sekarang kita menuju bagaimana langkah - langkah mengubah domain blogspot kita ke dot TK. 1. Masuk ke situs dot tk untuk melihat apakah domain yg kita inginkan tersedia atau tidak seperti pada gambar di bawah ini kemudian pilih GO 2. Kemudian masukkan url homepage blog anda pada kolom "Use your domain" dan pilih pilihan forward this domain to. Dan juga jangan lupa untuk memasukkan captcha yang tertera pada gambar dan pilih sign up 3. Pada langkah selanjutnya anda bisa memilih menggunakan akun facebook atau akun email untuk mendaftarkan domain yang anda inginkan. Akan tetapi disini saya akan mene

Laravel Training Purnama Academy

Nov 2018 Purnama Academy 0838-0838-0001 Kursus Laravel Training Center INdonesia, jakarta, Bandung, Bogor, Semarang, Yogya, Palembang kalimantan, surabaya visit www.purnamaacademy.com , Laravel - Online Courses, Classes, Training, Tutorials on Lynda https://www.lynda.com/Laravel-training-tutorials/2779-0.html Learn how to use Laravel, from beginner basics to advanced techniques, with online video tutorials taught by industry experts. Top Laravel Courses Online - Updated November 2018 | Udemy https://www.udemy.com/topic/laravel/ Whether you're interested in developing web apps in the Laravel PHP framework, or building a RESTful API with Laravel, Udemy has a course to help you ... PHP Laravel Framework | Brainmatics.Com brainmatics.com/php-laravel-framework/ Translate this page Laravel merupakan framework PHP yang dirancang untuk membangun situs web ... Pada training ini diharapkan mampu membantu meningkatkan kemampuan ... Dec 3 - Dec 6 Brainmatics Laravel training - Laracasts htt

Trainer Apache Spark, Trainer Hadoop Spark di Jakarta Bali, Bandung

Training Apache Spark Bersama peserta dari Telkomsel Jakarta (2018) di Multimatics yang merupakan salah satu IT training terkemuka di Indonesia. Terima kasih atas undangan dan peran serta nya. Materi yang diajarkan pada training apache Spark diantaranya : Mengenal Hadoop ecosystem, Instalasi Hadoop, Instalasi Apache Spark, pyspark, basic python, Mengenal Core Component Apache Spark, RDD, Pair RDD Transformation, Action , Dataframe vs Dataset, flatmap vs map, advanced topic Accumulators, Spark Sql , spark streaming, mengenal  machine learning concept dan MLLib , mengenal graphx , materi dikemas dengan studi kasus dan bobot praktek hingga 75 persen Hery Purnama 081-223344506, certified inhouse trainer for training cobit, cisa, itil, pmbok, babok, SAD, software testing ISTQB, Data Management DMBOk, Business Analysis BABOK, Project management, IoT, BigData Hadoop, Spark Developer, UML, ITSM, Iso 20000, 27000, 27001, 38500, CMMI, CAPM, PMP, MS.Project, cisa, Primavera, Excel Vba Macro, Pyth