Skip to content

Commit 7750811

Browse files
committed
Add messaging service Python samples
1 parent 35318c8 commit 7750811

File tree

18 files changed

+253
-0
lines changed

18 files changed

+253
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
alpha_sender = client.messaging \
10+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
11+
.alpha_senders \
12+
.create(alpha_sender="My company")
13+
14+
print(alpha_sender.sid)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
did_delete = client.messaging \
10+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
11+
.alpha_senders(sid="AIc781610ec0b3400c9e0cab8e757da937") \
12+
.delete()
13+
14+
print(did_delete)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
alpha_sender = client.messaging \
10+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
11+
.alpha_senders(sid="AIc781610ec0b3400c9e0cab8e757da937") \
12+
.fetch()
13+
14+
print(alpha_sender.alpha_sender)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
alpha_senders = client.messaging \
10+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
11+
.alpha_senders \
12+
.list()
13+
14+
for alpha_sender in alpha_senders:
15+
print(alpha_senders.sid)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
service = client.messaging \
10+
.services \
11+
.create(friendly_name="My First Service")
12+
13+
print(service.sid)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
did_delete = client.messaging \
10+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
11+
.delete()
12+
13+
print(did_delete)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
service = client.messaging \
10+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
11+
.fetch()
12+
13+
print(service.friendly_name)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
services = client.messaging.services.list()
10+
11+
for service in services:
12+
print(services.sid)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
phone_numbers_sids = ["PN2a0747eba6abf96b7e3c3ff0b4530f6e",
10+
"PN557ce644e5ab84fa21cc21112e22c485",
11+
"PN2a0747eba6abf96b7e3c3ff0b4530f6e"]
12+
13+
for phone_numbers_sid in phone_numbers_sids:
14+
phone_number = client.messaging \
15+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
16+
.phone_numbers \
17+
.create(phone_number_sid=phone_numbers_sid)
18+
print(phone_number.sid)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
phone_number = client.messaging \
10+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
11+
.phone_numbers \
12+
.create(phone_number_sid="PN557ce644e5ab84fa21cc21112e22c485")
13+
14+
print(phone_number.sid)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
did_delete = client.messaging \
10+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
11+
.phone_numbers(sid="PN557ce644e5ab84fa21cc21112e22c485") \
12+
.delete()
13+
14+
print(did_delete)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
phone_number = client.messaging \
10+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
11+
.phone_numbers(sid="PN557ce644e5ab84fa21cc21112e22c485") \
12+
.fetch()
13+
14+
print(phone_number.country_code)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
phone_numbers = client.messaging \
10+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
11+
.phone_numbers \
12+
.list()
13+
14+
for phone_number in phone_numbers:
15+
print(phone_number.sid)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
short_code = client.messaging \
10+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
11+
.short_codes \
12+
.create(short_code_sid="SC3f94c94562ac88dccf16f8859a1a8b25")
13+
14+
print(short_code.sid)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
did_delete = client.messaging \
10+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
11+
.short_codes(sid="SC3f94c94562ac88dccf16f8859a1a8b25") \
12+
.delete()
13+
14+
print(did_delete)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
short_codes = client.messaging \
10+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
11+
.short_codes(sid="SC3f94c94562ac88dccf16f8859a1a8b25") \
12+
.fetch()
13+
14+
print(short_codes.country_code)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
short_codes = client.messaging \
10+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
11+
.short_codes \
12+
.list()
13+
14+
for short_code in short_codes:
15+
print(short_code.sid)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Download the Python helper library from twilio.com/docs/python/install
2+
from twilio.rest import Client
3+
4+
# Your Account Sid and Auth Token from twilio.com/console
5+
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6+
auth_token = "your_auth_token"
7+
client = Client(account_sid, auth_token)
8+
9+
service = client.messaging \
10+
.services(sid="MG2172dd2db502e20dd981ef0d67850e1a") \
11+
.update(inbound_request_url="http://www.example.com")
12+
13+
print(service.inbound_request_url)

0 commit comments

Comments
 (0)