javascript - How to determine the operator of a mobile phone number?
过去多啦不再A梦
过去多啦不再A梦 2017-05-19 10:17:52
0
5
570

Like the title, how did you do it? I searched a lot online, but I don’t know why it doesn’t work

var isChinaMobile = /^134[0-8]\d{7}$|^(?:13[5-9]|147|15[0-27-9]|178|18[2-478])\d{8}$/; //移动方面最新答复
var isChinaUnion = /^(?:13[0-2]|145|15[56]|176|18[56])\d{8}$/; //向联通微博确认并未回复
var isChinaTelcom = /^(?:133|153|177|18[019])\d{8}$/; //1349号段 电信方面没给出答复,视作不存在
var isOtherTelphone = /^170([059])\d{7}$/;//其他运营商
var utils = {
 checkMobile: function(telphone){
  telphone = this.trim(telphone);
  if(telphone.length !== 11){
   return this.setReturnJson(false, '未检测到正确的手机号码');
  }
  else{
   if(isChinaMobile.test(telphone)){
    return this.setReturnJson(true, '移动', {name: 'ChinaMobile'});
   }
   else if(isChinaUnion.test(telphone)){
    return this.setReturnJson(true, '联通', {name: 'ChinaUnion'});
   }
   else if(isChinaTelcom.test(telphone)){
    return this.setReturnJson(true, '电信', {name: 'ChinaTelcom'});
   }
   else if(isOtherTelphone.test(telphone)){
    var num = isOtherTelphone.exec(telphone);
    return this.setReturnJson(true, '', {name: ''});
   }
   else{
    return this.setReturnJson(false, '未检测到正确的手机号码');
   }
  }
 },
 setReturnJson: function(status, msg, data){
  if(typeof status !== 'boolean' && typeof status !== 'number'){
   status = false;
  }
  if(typeof msg !== 'string'){
   msg = '';
  }
  return {
   'status': status,
   'msg': msg,
   'data': data
  };
 }
}
过去多啦不再A梦
过去多啦不再A梦

reply all(5)
左手右手慢动作

You can try Taobao’s API
https://tcc.taobao.com/cc/jso...Here is the mobile phone number

For example: https://tcc.taobao.com/cc/jso...

Return format:

_GetZoneResult = {

mts:'1820000',
province:'四川',
catName:'中国移动',
telString:'18200000000',
areaVid:'30508',
ispVid:'3236139',
carrier:'四川移动'

}

迷茫

You need to find an interface for this, and direct judgment is not possible.

淡淡烟草味

I don’t know if it is original or copied from somewhere, so it cannot be used.
1. Does utils have a trim() method? This.trim(xxx) will cause an error.
2. The three regular expressions are incorrect and any number will return false

世界只因有你

For different operators, the front ones are different

PHPzhong

We used the Taobao interface before, but the request volume was large and sometimes the interface was not stable. So now we use the interface + search engine method instead.
Randomly use bing, 360, Baidu search engine query.

Request the search engine directly and then analyze the desired data from the response.

Not only can you check the operator, but you can also check the location ^_^

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template