Last active
July 29, 2016 20:04
-
-
Save nealrs/95698e1b0be45e919017980897a39ca6 to your computer and use it in GitHub Desktop.
Get caller Name from Twilio
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
def callerName(tel): | |
r = requests.get("https://lookups.twilio.com/v1/PhoneNumbers/"+tel, params={'Type': 'caller-name'}, auth=(sid, tok) ) | |
try: | |
# return a list of first, last, etc. names instead of 1 string | |
name = r.json()['caller_name']['caller_name'].split() | |
except Exception, e: | |
print "error getting caller name: "+ repr(e) | |
name=None | |
return name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment