From 034fc5a5f5263793e2fff55cda1f1627f80745d7 Mon Sep 17 00:00:00 2001 From: Roy Perez Date: Wed, 26 Jan 2022 09:40:52 -0500 Subject: [PATCH] Update phone-number-check-example-external.py Minor adjustments to make code compatible with Python 3.x. Fixed Print command (no longer an statement on python 3.x) as well as updated how to import quote & parse modules from urllib --- phone-number-check-example-external.py | 72 +++++++++++++------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/phone-number-check-example-external.py b/phone-number-check-example-external.py index 51a24a1..f9f6493 100644 --- a/phone-number-check-example-external.py +++ b/phone-number-check-example-external.py @@ -1,36 +1,36 @@ -# phone-number-example.py -# tested in python 2.7.12 -# implements phone number verification in Python - -# dependencies -# an account on developer.syniverse.com -# create an application using Applications -> new Applications -# enable phone number verification service ^ Gateway Services for the App in the App Settings Option -# 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'] - -# 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. -# the + needs to be encoded to %2B - -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 +# phone-number-example.py +# tested in python 3.8.12 +# implements phone number verification in Python + +# dependencies +# an account on developer.syniverse.com +# create an application using Applications -> new Applications +# enable phone number verification service ^ Gateway Services for the App in the App Settings Option +# copy the access token for the App below. + +import requests +from urllib.parse import quote +from urllib.parse import urljoin + +number_list = ['+447860438585', + '+447513005998', + '+442079202200', + '+446543211234', + '+18136375000'] + +# 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. +# the + needs to be encoded to %2B + +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)