-
-
Save gspncr/21af231f54e410f8033b76637f8b6705 to your computer and use it in GitHub Desktop.
Print to the console voice/message activity and your numbers. Take this information to look at the numbers you own without logged calls/messages.
This file contains 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
TWILIO_ACCOUNT_SID=ACxxxxxxxxxx | |
TWILIO_AUTH_TOKEN=xxxxxxxxx |
This file contains 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
import os | |
from dotenv import load_dotenv | |
from twilio.rest import Client | |
load_dotenv() | |
# Find your Account SID and Auth Token at twilio.com/console | |
# and set the environment variables. See http://twil.io/secure | |
account_sid = os.environ['TWILIO_ACCOUNT_SID'] | |
auth_token = os.environ['TWILIO_AUTH_TOKEN'] | |
client = Client(account_sid, auth_token) | |
# Retrieve a list of the calls that have happened in our account | |
# and optionally provide a status and limit | |
calls = client.calls.list(status='completed', limit=20) | |
print ('\033[1;31mCalls \033[0m') | |
for record in calls: | |
call = client.calls(record.sid).fetch() | |
print('Call SID: ', record.sid, ' From: ',call.from_, ' Call End Time: ', call.end_time) | |
messages = client.messages.list(limit=20) | |
print ('\033[1;32mMessages \033[0m') | |
for record in messages: | |
if (record.direction == 'outbound-api'): | |
print('Message SID: ', record.sid, ' From: ', record.from_) | |
# Retrieve a list of the numbers our account has purchased | |
# and optionally provide a limit | |
incoming_phone_numbers = client.incoming_phone_numbers.list(limit=20) | |
print ('\033[1;34mNumbers \033[0m') | |
for record in incoming_phone_numbers: | |
print('Number SID: ', record.sid, ' Number: ', record.phone_number, ' Number Status: ', record.status, ' Number Friendly Name: ', record.friendly_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment