Code Samples

Perl

We offer code samples to make it easy for you to plug in SMS functionality into your applications.Download our SDK that contains sample projects in many languages or go straight to the language you need with our code samples. Code Sample #!/usr/bin/perl -w$file=”cgi-lib”;do $file || die “Fatal Error: Can’t load cgi library – $file\n”;&ReadParse;use CGI qw(:all);use LWP::UserAgent;$ua …

Perl Read More »

VB.NET

We offer code samples to make it easy for you to plug in SMS functionality into your applications. Download our SDK that contains sample projects in many languages or go straight to the language you need with our code samples. Code Sample Public Class MessageDim postURL As String = “http://gateway.2sms.us/xml/xml.jsp” Dim username As StringDim password As StringSub …

VB.NET Read More »

VBA

We offer code samples to make it easy for you to plug in SMS functionality into your applications. Code Sample Sub test()     Dim xmlstring As String     Username = “user@mailaddress.com”    Password = “yourpass”    Message = “Your Message Here”    Destination = “447777777777”    xmlstring = “<?xml version=” & Chr(34) & “1.0” & Chr(34) & “?> ” …

VBA Read More »

Python

We offer code samples to make it easy for you to plug in SMS functionality into your applications. Code Sample #!/usr/bin/env python import httplib def sendSMS(username, password,destination, message):        body = “<?xml version=\”1.0\” encoding=\”UTF-8\” ?>”+\               “<Request xmlns:xsi=\”http://www.w3.org/2001/XMLSchema-instance\”” +\   :noNamespaceSchemaLocation=\”http://schema.2sms.us/1.0/0410_RequestSendMessage.xsd\”   ” +\        “Version=\”1.0\”><Identification>” +\        “<UserID>” + username +”</UserID>” +\        “<Password>”+password+”</Password>” +\        “</Identification>” +\        “<Service>” +\        “<ServiceName>SendMessage</ServiceName>” +\        …

Python Read More »

PHP

We offer code samples to make it easy for you to plug in SMS functionality into your applications. Code Sample $user = ‘user@company.com’;$pass = ‘myPassword’; $text = substr($HTTP_POST_VARS[‘text’], 0, 160); $mobnum = $HTTP_POST_VARS[‘mobnum’]; $result = ”; $myOutMsg = ‘<?xml version=”1.0″ encoding=”UTF-8″ ?>’;$myOutMsg .= ‘<Request xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” ‘;$myOutMsg .= ‘xsi:noNamespaceSchemaLocation=”http://schema.2sms.us/1.0/0410_RequestSendMessage.xsd” ‘;$myOutMsg .= ‘Version=”1.0″>’;$myOutMsg .= ‘<Identification>’;$myOutMsg .= ‘<UserID>’ …

PHP Read More »

Java

We offer code samples to make it easy for you to plug in SMS functionality into your applications.Download our SDK that contains sample projects in many languages or go straight to the language you need with our code samples. Code Sample package com.twoSms; import java.io.OutputStreamWriter;import java.net.URL;import java.net.URLConnection; import javax.xml.parsers.DocumentBuilder;import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class SmsJava{    …

Java Read More »

C#

private string formXml(string username, string password, string destination, string message){ // create xml stringstring xmlString = “<?xml version=\”1.0\” encoding=\”UTF-8\” ?> ” +“<Request xmlns:xsi=\”http://www.w3.org/2001/XMLSchema-instance\” xsi:noNamespaceSchemaLocation=\”http://schema.2sms.us/1.0/0410_RequestSendMessage.xsd\” 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>” +“</Request>”; return xmlString;} private string sendXml(string xmlDoc){  string …

C# Read More »

Scroll to Top