Secure Login

We offer code samples to make it easy for you to plug in SMS functionality into your applications.

Download our SDK containing sample projects in many languages or go straight to the language you need with our code samples.

#!/usr/bin/env python

import httplib

def sendSMS(username, password,destination, message):
        body = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"+\
               "<Request xmlns:xsi=\"\"" +\
   :noNamespaceSchemaLocation=\"\"   " +\
        "Version=\"1.0\"><Identification>" +\
        "<UserID>" + username +"</UserID>" +\
        "<Password>"+password+"</Password>" +\
        "</Identification>" +\
        "<Service>" +\
        "<ServiceName>SendMessage</ServiceName>" +\
        "<ServiceDetail>" +\
        "<SingleMessage>" +\
        "<Destination>"+destination+"</Destination>" +\
        "<Text>"+message+"</Text>" +\
        "</SingleMessage>" +\
        "</ServiceDetail>" +\
        "</Service>" +\
    h = httplib.HTTP('')
    h.putheader('Content-length',"%d" % len(body))
    reply, msg, hdrs = h.getreply()
    if reply != 200:
         raise RuntimeError('HTTP request error',(reply,msg,hdrs))
    print "HTTP request to 2sms OK"  

username = ''
password = 'password'
destination = raw_input("Enter a destination Mobile: ")
message = raw_input("Type your message: ")
### pause for Return key (so window doesn't disappear)
raw_input('press Return to exit>')
©2sms Business Text Messaging,2018