CardBoardFish.com
CardBoardFish SMS MT - HTTPSMS, SMPP & UCP-EMI and CIMD2.
+ Search:
+ Quick login:
  • Batch Sender
  • Send large volumes of SMS
  • No software to install
  • Upload large lists of numbers
  • More...
  • Number Validation
  • Clean up your number lists
  • Indentify ported numbers
  • Stop sending to failed numbers
  • More...
  • SMS MT
  • A choice of protocols
  • Connect directly to our gateway
  • Free to signup
  • More...
  • SMS MO
  • Your own virtual mobile number
  • Receive incoming SMS
  • Intergrate with your applications
  • More...
See pricing and services suitable for your needs:
How many text messages do you plan to send each month?
What do you use text messaging for?
How can we help you do this?
- from
Click Here to Contact Us

HTTPSMS Code Examples: This page contains example code for sending an SMS via HTTPSMS in a range of popular languages. Click the language that you are interested in to view the example and, if required, download the full API package.

Send SMS with .NET:

Code:

'Example Visual Basic.NET code to send an SMS to the recipient '447000000001', with sender set to 'James' and message 'Hello'.

'First include the HTTPSMS dynamic link library-

Imports HTTPSMS

Module SendTextMessage

Sub Main()

	'Build a try/catch tree to catch any errors

	Try

		'Next, set our destination telephone number:

		Dim destination() As String = {"447000000001"}

		'And our source (who the recipient will see as 'sender'):

		Dim source As String = "James"

		'Create a new SMS object to hold our message

		Dim ourSMS As New SMS

		'Populate this SMS object with our message information, including destination, source, message etc.

		ourSMS.SMS(destination, source, Nothing, "Hello", "0", "1", Nothing, "MSG_1", Nothing, Nothing, Nothing)

		'Create a new SendSMS object

		Dim ourSendSMS As New SendSMS

		'Now set our username and password:

		Dim username As String = "user01"

		Dim password As String = "pass01"

		'Get ourSendSMS ready by initialising it with our username and password:

		ourSendSMS.initialise(username, password)

		'Now send ourSMS using the ourSendSMS object, capturing the responses with an array 'responses()'

		Dim responses() As Integer = ourSendSMS.SendSMS(ourSMS)

		'Let the user know we are about to print the server responses:
		
		Console.WriteLine("Console responses: ")

		Dim i As Integer = 0

		'Now for all our server responses, print them to screen:

		While i < responses.Length

			Console.WriteLine(responses(i))

			i = i + 1

		End While

		Console.ReadLine()

		'Catch any errors, and handle them by printing their output to screen

		Catch sendSMSEx As HTTPSMS.SMSClientException

		'Print the error message

		Console.WriteLine(sendSMSEx.errMessage)

		Return

	End Try

End Sub

End Module

(click anywhere in the text to highlight then rightclick, copy to copy to clipboard)

Send SMS with PHP:

Code:

<?php
# Example PHP code to send an SMS to the recipient '447000000001', with sender set to 'James' and message 'Hello'.

print "Initialising library...\n";
require_once("SendSMS.php");
# Set global username and password for use by the library
$sms_username = "user01";
$sms_password = "pass01";
print "Library initialised.\n";

# Send a message to 447000000001 with sender 'James' and message 'Hello'
# SourceTON (type of number) will be set automatically by the library.
$destination = "447000000001";
$source = "James";
$message = "Hello";
print "Sending message...\n";
$responses = send_sms($destination, $source, $message) or die ("Error: " . $errstr . "\n");
print "Message sent.\n";

# Print the response to the screen
print "Responses from the server:\n";
foreach ($responses as $response) {
echo "\t$response\n";
}
?>

(click anywhere in the text to highlight then rightclick, copy to copy to clipboard)

Send SMS with PERL:

Code:

#!/usr/bin/perl -w

# Example Perl code to send an SMS to the recipient '447000000001', with sender set to 'James' and message 'Hello'.

use strict;

use SendSMS;
use SMS;

# Initialise the library
my $username = "user01";
my $password = "pass01";

print "Initialising library...\n";
SendSMS::initialise($username, $password) or die SendSMS->errstr;
print "Library initialised.\n";

# Send a message to 447000000001 with sender 'James' and message 'Hello'
# SourceTON (type of number) will be set automatically by the library.
my $destination = "447000000001";
my $source =      "James";
my $message =     "Hello";
print "Sending message...\n";
my @responses = SendSMS::sendSMS($destination, $source, $message) or die SendSMS->errstr;
print "Message sent.\n";

# Print the response to the screen
print "Responses from the server:\n";
foreach my $response (@responses) {
    print "\t$response\n";
}

(click anywhere in the text to highlight then rightclick, copy to copy to clipboard)

Send SMS with JAVA:

Code:

/**
 *  Example.java
 *
 *  Example Java code to send an SMS to the recipient  '447000000001',
 *  with sender set to 'James' and message 'Hello'.
 *
 *  Build:
 *      javac -classpath cbfsms.jar Example.java
 *
 *  Run:
 *      java -classpath cbfsms.jar:. Example
 *
 */

import CBFSMS.*;

public class Example {

    /* Username and password of your CardBoardFish HTTPSMS account */
    private static final String username = "user01";
    private static final String password = "pass01";

    public static void main(String[] args) {
        try {
            /* Initialise the library */
            System.out.println("Initialising library...");
            SendSMS.initialise(username, password);
            System.out.println("Library initialised.");

            /* Send a message to 447000000001 with sender 'James' and message 'Hello'. SourceTON (type of number) will be set automatically by the lobrary. */

            /* This could be given as a single string, in which case
               the sendSMS method returns a single integer. */
            String[] destination = { "447000000001" };
            String source      = "James";
            String message     = "Hello";
            System.out.println("Sending message...");
            int[] responses = SendSMS.sendSMS(destination, source, message);
            System.out.println("Message sent.");

            /* Print the responses to the screen */
            System.out.println("Responses from the server:");
            for (int i = 0; i < responses.length; i++) {
                System.out.println("\t" + responses[i]);
            }
            
        } catch (SMSClientException e) {
            System.err.println(e.getMessage());
        }
    }

}

(click anywhere in the text to highlight then rightclick, copy to copy to clipboard)

Send SMS with PYTHON:

Code:

#!/usr/bin/env python

# Example Perl code to send an SMS to the recipient '447000000001', with sender set to 'James' and message 'Hello'.

from SendSMS import *
import SendSMS

# Username and password of a CardBoardFish HTTPSMS account
username = "user01"
password = "pass01"

try:
    # Initialise the library
    print "Initialising library..."
    SendSMS.init(username,password)
    print "Library initialised."

    # Send a message to 447000000001 with sender 'James' and message 'Hello'
    # SourceTON (type of number) will be set automatically by the library.
    destination = "447000000001"
    source =      "James"
    message =     "Hello"

    print "Sending message...";
    responses = sendSMS({ 'da': destination, 'sa': source, 'm': message })
    print "Message sent.";

    # Print the response to the screen
    print "Responses from the server:"
    for response in responses:
        print "\t" + response
except SMSClientError, e:
    print e

(click anywhere in the text to highlight then rightclick, copy to copy to clipboard)

Pay us with Paypal, Google checkout, Maestro, Delta, JCB, Mastecard, Visa, Visa Electron, American Express