diff --git a/phone-number-check-example-external.py b/phone-number-check-example-external.py index 51a24a1..743001a 100644 --- a/phone-number-check-example-external.py +++ b/phone-number-check-example-external.py @@ -1,5 +1,7 @@ # phone-number-example.py # tested in python 2.7.12 +# New version adpated to work with Python 3 +# tested in Python 3.6.1 # implements phone number verification in Python # dependencies @@ -9,14 +11,21 @@ # copy the access token for the App below. import requests -from urllib import quote -from urlparse import urljoin - -number_list = ['+447860438585', - '+447513005998', - '+442079202200', - '+446543211234', - '+18136375000'] +from urllib.parse import quote +from urllib.parse import urljoin + +#Below are MSISDN's samples redacting the last 4 digits + +number_list = ['+1201221XXXX', + '+1704661XXXX', + '+1315512XXXX', + '+1317946XXXX', + '+1918844XXXX' + '+23324469XXXX' + '+3579934XXXX' + '+3630708XXXX' + '+4179643XXXX' + '+44748287XXXX'] # this is the base url for the phone number verification service, last element in url is # replaced with the encoded phone number in international format. @@ -25,12 +34,12 @@ base_url = 'https://api.syniverse.com/numberidentity/v3/numbers/[phonenumber]' access_token = '{YOUR ACCESS TOKEN HERE}' - headers = {'Authorization': 'Bearer ' + access_token, 'Content-Type': 'application/json'} for number in number_list: # make the url for the lookup including quoting the + correctly) url = urljoin(base_url,quote(number)) response = requests.get(url, headers=headers) - print 'status code: ' + str(response.status_code) - print 'response: ' + response.text + print ("Response = ", response) + print ('status code: ' , str(response.status_code)) + print ('response: ' , response.text)