- In a python environment that has pip installed, do
pip install twilio
thenpip install phonenumbers
. - Do
python risky-account-finder.py
Created
October 4, 2012 00:43
-
-
Save TMcManus/3830824 to your computer and use it in GitHub Desktop.
Risky Account Finder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twilio.rest import TwilioRestClient | |
import phonenumbers | |
ACCOUNT_SID = "ACXXXXXXX" // Your Account SID | |
AUTH_TOKEN = "YYYYYYY" //Your Auth Token | |
# List the country codes you want to check for here | |
risky_countries = ['370', '359', '355', '381', '509', '994', '297', '232'] | |
def figure_out_country(phone_number): | |
try: | |
x = phonenumbers.parse(phone_number, None) | |
return str(x.country_code) | |
# Don't fail on the numerous exceptions | |
except phonenumbers.phonenumberutil.NumberParseException: | |
return "Other" | |
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN) | |
subaccounts = client.accounts.list() | |
for subaccount in subaccounts: | |
call_list = subaccount.calls.list() | |
for call in call_list: | |
country_code = figure_out_country(call.to) | |
if country_code in risky_countries: | |
print "%s|%s|%s|%s|%s" % (country_code, call.to, subaccount.friendly_name, subaccount.sid, subaccount.status) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment