Skip to content

Adapted version to run in Python 3 no new functionality added to the … #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions phone-number-check-example-external.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand All @@ -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)