1

I want to implement phone number validation which checks whether phone number exist or does not exist.

I did this

Imports Twilio.Lookups

If Not File.Exists("list.txt") Then
         MsgBox("insert phone numbers to list.txt")

         Return
     Else
         Dim list() As String = File.ReadAllLines("list.txt")
         ListBox1.Items.AddRange(list)



     End If

     Dim accountSid As String = "AC862c52baff7d8ef72c9e4c04f828fa03"
     Dim authToken As String = "xxxxxxxxxxxx"
     Dim lookups As New LookupsClient(accountSid, authToken)
For Each str4 In ListBox1.Items
    Dim phoneNumber = lookups.GetPhoneNumber(str4, True)
    If ((((Not phoneNumber.Carrier Is Nothing) AndAlso (Not phoneNumber.Carrier.Name Is Nothing)) AndAlso ((Not phoneNumber.NationalFormat Is Nothing) AndAlso (Not phoneNumber.PhoneNumber Is Nothing))) AndAlso (Not phoneNumber.CountryCode Is Nothing)) Then
        Console.WriteLine(phoneNumber.Carrier.Name)
    ElseIf (Not phoneNumber.RestException Is Nothing) Then
        Console.WriteLine(phoneNumber.RestException.Message)
    Else
        Console.WriteLine("Phone number was correct, although the carrier who owns it was not found.")
    End If


Next

but this only does carrier lookup, it does not check if the actual phone number exists.

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
softfx
  • 39
  • 7
  • What have you tried and what was the result? As you did in school... please show your work. :) It's part of the process of getting questions answered on SO. It's helpful to you because it forces you to investigate your own problem and think it through. It also proves to readers that you did your homework and made a reasonable attempt to answer your own question. Thirdly, it helps readers find and diagnose the problem resulting in a better answer for you and less time wasted for us. – JeffC Oct 25 '15 at 00:38
  • i edit code . this is what i coded until now. thanks – softfx Oct 25 '15 at 00:47

2 Answers2

1

Twilio developer evangelist here.

The best way to validate the existence of a phone number is to send an SMS message or make a phone call providing the user with a code that they then need to enter back into your application to show that they got it on that phone. Just using the Lookups functionality of the Twilio API will tell you if the phone number is a phone number, but not whether anyone owns it or uses it with a phone.

There is a good example of how to do phone verification with PHP on the Twilio Blog. There is also an example of phone verification with Ruby on Rails. Hopefully they can help you build out your solution.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • i plan to use phone verification for send sms marketing . but before start sms marketing i want to remove not existed phone number that why i making phone verification system. i checked 'how to do phone verification with php' but it not suitable for use my system because it have to insert verification code by phone user. are there any other feasible solution for me? thanks philnash ! – softfx Oct 26 '15 at 09:28
  • So, you can check using the lookups API but much like an email, you could tell if looks like a number, but the only real way to confirm it exists and is owned by someone is to verify it by sending a message and getting that confirmed. – philnash Oct 26 '15 at 09:34
0

I would suggest using regular expressions and reading this related article.

Community
  • 1
  • 1
k4yaman
  • 475
  • 8
  • 20
  • my question is not related with phone number format check .i want to check actual existence phone number. so i can guess i need to lookup actual existence of phone number but couldn't found some tip or code in google or twilio web. – softfx Oct 25 '15 at 00:43