Message-ID: <127482154.15671.1614957458140.JavaMail.confluence@wiki> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_15670_1791608664.1614957458140" ------=_Part_15670_1791608664.1614957458140 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Text Marketer Developer Documentation - Wiki Home

Text Marketer Developer Documentation - Wiki Home

=20
=20
=20
=20
=20
=20
=20
=20
=20
=20

 

=20
=20
=20
=20
=20
=20

Welcome to the Text Marketer wiki. Here you will find all the informatio= n you need on how to use our SMS applications.

=20
=20
=20
=20
=20
=20

Here you will find:

=20
=20
=20 =20
=20
=20
=20

You can download any of the information you need in a PDF. To do this ju= st simply go to the 'tools' button in the top right hand corner and choose = Export to PDF. If you want to download more than one page, select 'Browse' = on the top bar and choose 'Space Operations' and on the left you will have = your Export options.

=20
=20
=20
=20
=20
=20

Want to start instantly?

=20
=20
=20
=20
=20
=20

Just look at these code examples below and copy and paste them in t= o be sending SMS instantly, if you don't have an account you can register <= strong>here and get 10 free text= credits

=20
=20
=20
=20
=20
=20
=20
=20 =20
=20
=20
<?php
    // Simple SMS send function
    function sendSMS($username, $password, $to, $message, $originator) {
        $URL =3D 'https://api.textmarketer.co.uk/gateway/'."?username=
=3D$username&password=3D$password&option=3Dxml";
        $URL .=3D "&to=3D$to&message=3D".urlencode($messa=
ge).'&orig=3D'.urlencode($originator);
        $fp =3D fopen($URL, 'r');
        return fread($fp, 1024);
    }
    // Example of use=20
    $response =3D sendSMS('myUsername', 'myPassword', '4477777777', 'My tes=
t message', 'TextMessage');
    echo $response;?>
=20
=20
=20
=20
=20
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

// Simple send SMS programm
public class SendSMS {
    public static String sendSMS(String username, String password, String t=
o, String message, String originator) {
        String url;
        StringBuilder inBuffer =3D new StringBuilder();
        try {
            url =3D "https://api.textmarketer.co.uk/gateway/" +
                "?username=3D" + username + "&password=
=3D" + password + "&option=3Dxml" +
                "&to=3D" + to + "&message=3D" +=
 URLEncoder.encode(message, "UTF-8") +
                "&orig=3D" + URLEncoder.encode(originator, &q=
uot;UTF-8");
        } catch (UnsupportedEncodingException e) {
            return null;
        }
        try {
            URL tmUrl =3D new URL(url);
            URLConnection tmConnection =3D tmUrl.openConnection();
            tmConnection.setDoInput(true);
            BufferedReader in =3D new BufferedReader(new InputStreamReader(=
tmConnection.getInputStream()));
            String inputLine;
            while ((inputLine =3D in.readLine()) !=3D null)
                inBuffer.append(inputLine);
            in.close();
        } catch (IOException e) {
            return null;
        }
        return inBuffer.toString();
    }
    public static void main(String[] args) {
        // Example of use=20
        String response =3D sendSMS("myUsername", "myPasswor=
d", "4477777777", "My test message", "TextMes=
sage");
        System.out.println(response);
    }
}
=20
=20
=20
=20
=20
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Web;

namespace SendSMS {
    class Program {
        public static string SendSMS(string username, string password, stri=
ng to, string message, string originator) {
            StringBuilder sb  =3D new StringBuilder();
            byte[]        buf =3D new byte[1024];
            string url =3D "https://api.textmarketer.co.uk/gateway/&qu=
ot; +
                "?username=3D" + username + "&password=
=3D" + password + "&option=3Dxml" +
                "&to=3D" + to + "&message=3D" +=
 HttpUtility.UrlEncode(message) +
                "&orig=3D" + HttpUtility.UrlEncode(originator=
);
            HttpWebRequest request =3D (HttpWebRequest)WebRequest.Create(ur=
l);
            HttpWebResponse response =3D (HttpWebResponse)request.GetRespon=
se();
            Stream resStream =3D response.GetResponseStream();
            string tempString =3D null;
            int count =3D 0;
            do {
                count =3D resStream.Read(buf, 0, buf.Length);
                if (count !=3D 0) {
                    tempString =3D Encoding.ASCII.GetString(buf, 0, count);
                    sb.Append(tempString);
                }
            }
            while (count > 0);
            return sb.ToString();
        }
        static void Main(string[] args) {
            string respXML =3D SendSMS("myUsername", "myPass=
word", "4477777777", "My test message", "Text=
Message");
            Console.WriteLine(respXML);
       }
    }
}
=20
=20
=20
=20
=20
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Web;

namespace SendSMS {
    class Program {
        public static string SendSMS(string username, string password, stri=
ng to, string message, string originator) {
            StringBuilder sb  =3D new StringBuilder();
            byte[]        buf =3D new byte[1024];
            string url =3D "https://api.textmarketer.co.uk/gateway/&qu=
ot; +
                "?username=3D" + username + "&password=
=3D" + password + "&option=3Dxml" +
                "&to=3D" + to + "&message=3D" +=
 HttpUtility.UrlEncode(message) +
                "&orig=3D" + HttpUtility.UrlEncode(originator=
);
            HttpWebRequest request =3D (HttpWebRequest)WebRequest.Create(ur=
l);
            HttpWebResponse response =3D (HttpWebResponse)request.GetRespon=
se();
            Stream resStream =3D response.GetResponseStream();
            string tempString =3D null;
            int count =3D 0;
            do {
                count =3D resStream.Read(buf, 0, buf.Length);
                if (count !=3D 0) {
                    tempString =3D Encoding.ASCII.GetString(buf, 0, count);
                    sb.Append(tempString);
                }
            }
            while (count > 0);
            return sb.ToString();
        }
        static void Main(string[] args) {
            string respXML =3D SendSMS("myUsername", "myPass=
word", "4477777777", "My test message", "Text=
Message");
            Console.WriteLine(respXML);
       }
    }
}
=20
=20
=20
=20
=20
/* * Send SMS C/C++ example need curllib download from http://curl.hax=
x.se/ */

#include <stdio.h>
#include <tchar.h>
#include <string.h>
#include <curl/curl.h>
#define URLSIZE 256

struct MemoryStruct {
        char *memory;
        size_t size;
};

/* Converts a hex character to its integer value */

char from_hex(char ch) {
        return isdigit(ch) ? ch - '0' : tolower(ch) - 'a' + 10;
}

/* Converts an integer value to its hex character*/

char to_hex(char code) {
        static char hex[] =3D "0123456789abcdef";
        return hex[code & 15];
}

/* Returns a url-encoded version of str */

char *url_encode(char *str) {
        char *pstr =3D str, *buf =3D (char *)malloc(strlen(str) * 3 + 1), *=
pbuf =3D buf;
        while (*pstr) {
                if (isalnum(*pstr) || *pstr =3D=3D '-' || *pstr =3D=3D '_' =
|| *pstr =3D=3D '.' || *pstr =3D=3D '~')
                        *pbuf++ =3D *pstr;
                else if (*pstr =3D=3D ' ')
                        *pbuf++ =3D '+';
                else
                        *pbuf++ =3D '%', *pbuf++ =3D to_hex(*pstr >> =
4), *pbuf++ =3D to_hex(*pstr & 15);
                pstr++;
        }
        *pbuf =3D '\0';
        return buf;
}

/* CURL Callback write function */

static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb=
, void *userp) {
        size_t realsize =3D size * nmemb;
        struct MemoryStruct *mem =3D (struct MemoryStruct *)userp;
        mem->memory =3D (char *)realloc(mem->memory, mem->size + r=
ealsize + 1);
        if (mem->memory =3D=3D NULL) {
                /* out of memory! */
                printf("not enough memory (realloc returned NULL)\n&qu=
ot;);
                exit(EXIT_FAILURE);
        }
        memcpy(&(mem->memory[mem->size]), contents, realsize);
        mem->size +=3D realsize;
        mem->memory[mem->size] =3D 0;
        return realsize;
}

/* Send SMS */

char * sendSMS(const char *username, const char *password, const char *to, =
char *message, char *originator) {
        static char url[URLSIZE] =3D "https://api.textmarketer.co.uk/g=
ateway/?option=3Dxml";
        char *encoded;
        CURL *curl;
        CURLcode res;
        struct MemoryStruct chunk;
        chunk.memory =3D (char *)malloc(1);  /* will be grown as needed by =
the realloc above */
        chunk.size =3D 0;    /* no data at this point */
        curl =3D curl_easy_init();
        if(curl) {
                strcat_s(url, URLSIZE, "&username=3D");
                strcat_s(url, URLSIZE, username);
                strcat_s(url, URLSIZE, "&password=3D");
                strcat_s(url, URLSIZE, password);
                strcat_s(url, URLSIZE, "&to=3D");
                strcat_s(url, URLSIZE, to);
                strcat_s(url, URLSIZE, "&message=3D");
                encoded =3D url_encode(message);
                strcat_s(url, URLSIZE, encoded);
                free(encoded);
                encoded =3D url_encode(originator);
                strcat_s(url, URLSIZE, "&orig=3D");
                strcat_s(url, URLSIZE, encoded);
                free(encoded);
                curl_easy_setopt(curl, CURLOPT_URL, url);
                /* send all data to this function  */
                curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCa=
llback);
                /* we pass our 'chunk' struct to the callback function */
                curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chun=
k);
                if((res =3D curl_easy_perform(curl)) !=3D CURLE_OK) {
                        return NULL;
                }
                curl_easy_cleanup(curl);
        }
        return chunk.memory;
}

int main(void) {
        char *response;
        response =3D sendSMS("myuser", "mypass", "=
4477777777", "test test test", "me");
        if(response !=3D NULL) {
                printf(response);
                free(response);
        }
        getchar();
        return 0;
}
=20
=20
=20
=20
=20
Imports System.Web

Module Module1
    Public Function SendSMS(ByVal username As String, ByVal password As Str=
ing, ByVal toPhone As String,
                            ByVal message As String, ByVal originator As St=
ring)
        Dim webClient As New System.Net.WebClient
        Dim url As String =3D "https://api.textmarketer.co.uk/gateway/=
?username=3D" &
                username & "&password=3D" & password =
& "&option=3Dxml" &
                "&to=3D" & toPhone & "&messa=
ge=3D" & System.Web.HttpUtility.UrlEncode(message) &
                "&orig=3D" & System.Web.HttpUtility.urlen=
code(originator)
        Dim result As String =3D webClient.DownloadString(url)
        SendSMS =3D result
    End Function

    Sub Main()
        Dim result As String =3D SendSMS("myUsername", "myPa=
ssword", "4477777777", "My test message", "Te=
xtMessage")
        Console.WriteLine(result)
        Console.ReadKey()
    End Sub

End Module
=20
=20
=20
=20
=20
<%@language=3DJScript%><%
    username =3D "myUsername";
    password =3D "myPassword";
    to =3D "4477777777";
    message =3D Server.URLEncode("My test message");
    originator  =3D Server.URLEncode("TextMessage");
    url =3D "https://api.textmarketer.co.uk/gateway/?&option=3Dxml=
" +
            "&username=3D" + username + "&password=
=3D" + password +
            "&to=3D" + to + "&message=3D" + mes=
sage +
            "&orig=3D" + originator;
    var objSrvHTTP;
    objSrvHTTP =3D Server.CreateObject("Msxml2.ServerXMLHTTP");
    objSrvHTTP.open(url, false);
    objSrvHTTP.send();
    Response.ContentType =3D "text/xml";
    xmlResp =3D objSrvHTTP.responseXML.xml;
    Response.Write(xmlResp);%>
=20
=20
=20
=20
=20
require 'net/http'
require 'uri'

def send_sms(username, password, to, message, originator)
  requested_url =3D 'https://api.textmarketer.co.uk/gateway/?option=3Dxml' =
+
                "&username=3D" + username + "&passwo=
rd=3D" + password +
                "&to=3D" + to + "&message=3D" +=
 URI.escape(message) +
                "&orig=3D" + URI.escape(originator)
  url =3D URI.parse(requested_url)
  full_path =3D (url.query.blank?) ? url.path : "#{url.path}?#{url.que=
ry}"
  the_request =3D Net::HTTP::Get.new(full_path)
  the_response =3D Net::HTTP.start(url.host, url.port) { |http|
    http.request(the_request)
  }
  raise "Response was not 200, response was #{the_response.code}"=
 if the_response.code !=3D "200"
  return the_response.bodyend
resp =3D send_sms('myUsername', 'myPassword', '4477777777', 'My test messag=
e', 'TextMessage')

puts(resp)
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20

If you don't know your API username and password, you'll find them when = you log on to the Text Marketer web interface here: 

https://messagebox.textmarketer.co.uk/(Account Settings > API Setti= ngs)

Need something else?

Please don=E2=80=99t hesitate to contact us.=

We are here to help.

=20
=20
=20
=20
=20 =20
------=_Part_15670_1791608664.1614957458140--