File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ #Day 27 & 28
2+
3+ import requests
4+
5+ username = 'ACe96e664d910ae38b8cd106083f24cdfd' #account_sid
6+ account_sid = username
7+ password = '67ef145171db841d137dd8f02baf1aae' #auth_token
8+
9+ number_to_text = '+19494413233' #+1-(949)-441-3233
10+ twilio_number = '+17472332016' #+1-(747)-233-2016
11+
12+ message_body = ''
13+
14+ def xml_pretty (xml_string ):
15+ import xml .dom .minidom
16+ xml = xml .dom .minidom .parseString (xml_string )
17+ pretty_xml_ = xml .toprettyxml ()
18+ print (pretty_xml_ )
19+
20+
21+ base_url = 'https://api.twilio.com/2010-04-01/Accounts'
22+ message_url = base_url + '/' + account_sid + '/Messages'
23+ auth_cred = (username , password )
24+
25+ post_data = {
26+ "From" : twilio_number ,
27+ "To" : number_to_text ,
28+ "Body" : message_body ,
29+ "MediaUrl" : "http://img2.10bestmedia.com/Images/Photos/96123/captiva-beach-captiva_54_990x660_201404211817.jpg" #img,
30+ }
31+
32+ r = requests .post (message_url , data = post_data , auth = auth_cred )
33+
34+ print (r .status_code )
35+ xml_pretty (r .text )
36+
37+
38+ message_url_ind = message_url + "/MMa63006dc4c36470abb69132c0aea23ef"
39+ get_r = requests .get (message_url_ind , auth = auth_cred )
40+
41+ xml_pretty (get_r .text )
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
You can’t perform that action at this time.
0 commit comments