Skip to content

Update phone-number-check-example-external.py #2

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
72 changes: 36 additions & 36 deletions phone-number-check-example-external.py
Original file line number Diff line number Diff line change
@@ -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)