Tuesday, October 28, 2008

aspsms.com - Examples - XML - Python - SMS

aspsms.com - Examples - XML - Python - SMS:

"The following example in Python has been sent to us by a client which uses this script language to connect to our XML-gateway.

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

import socket

HOST = 'xml1.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='''

'''+str(userkey)+'''
'''+str(password)+'''
'''+ str(originator) +'''

'''+ str(recipient) +'''

'''+ str(text) +'''
SendTextSMS
'''

length=len(CONTENT)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.send('POST /xmlsvr.asp HTTP/1.0\r\n')
s.send('Content-Type: text/xml\r\n')
s.send('Content-Length: '+str(length)+'\r\n\r\n')
s.send(CONTENT)
datarecv=s.recv(1024)
print 'Reply Received: '+ str(data"