Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

send xml data with python

#!/usr/bin/python2
print 'Content-Type: text/html'
print # Blank line marking end of HTTP headers

import socket

HOST = 'xml3.aspsms.com' # The remote host
PORT = 5061 # The same port as used by the server
userkey = #please fill in your USERKEY
password = #please enter your PASSWORD
originator = #please fill in the ORIGINATOR
recipient = #please insert the RECIPIENT here
text = #Your SMS Text

CONTENT="""<?xml version="1.0" encoding="ISO-8859-1"?>
  <aspsms>
   <Userkey>"""+str(userkey)+"""</Userkey>
    <Password>"""+str(password)+"""</Password>
    <Originator>"""+ str(originator) +"""</Originator>
    <Recipient>
    <PhoneNumber>"""+ str(recipient) +"""</PhoneNumber>
    </Recipient>
    <MessageData>"""+ str(text) +"""</MessageData>
    <Action>SendTextSMS</Action>
    </aspsms>"""

length=len(CONTENT)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.send("POST /xmlsvr.asp HTTP/1.0
")
s.send("Content-Type: text/xml
")
s.send("Content-Length: "+str(length)+"

")
s.send(CONTENT)
datarecv=s.recv(1024)
print "Reply Received: "+ str(datarecv)
s.close()
Comment

PREVIOUS NEXT
Code Example
Python :: gevent with flask 
Python :: add favicon in django admin 
Python :: how to make a grid in python 
Python :: python type annotations list of possible values 
Python :: heapsort python 
Python :: python added dictionary together 
Python :: matplotlib limit number of ticks 
Python :: python file save 
Python :: create exact window size tkinter 
Python :: DIVAB 
Python :: python how to replace a string in a list 
Python :: python button tkinter change color 
Python :: drop duplicates data frame pandas python 
Python :: Subset data frame by date 
Python :: list to text python 
Python :: print on same line 
Python :: django 
Python :: regular expression syntax python 
Python :: python - gropuby based on 2 variabels 
Python :: django content type for model 
Python :: streamlit - Warning: NumberInput value below has type int so is displayed as int despite format string %.1f. 
Python :: matplotlib pie edge width 
Python :: pop function in python 
Python :: pygame pin to top 
Python :: add output to setting scrapy 
Python :: ndarray python 
Python :: fetch firestore indexes 
Python :: python decomposition facteur premier 
Python :: query set 
Python :: Average of total in django querysets 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =