-
Notifications
You must be signed in to change notification settings - Fork 3
/
phone-number-check-example-external.py
36 lines (28 loc) · 1.29 KB
/
phone-number-check-example-external.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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