Get connected with your SMS API-key.
To quickly test single or basic multiple messages via our API when using an API-key, choose to generate either a GET or POST request, then simply change the fields below highlighted in red to your relevant information.
Or, for those that intend to integrate or test using a traditional username and password API, please click the button below to view the example code when using our legacy API.
-
https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage&apikey=APIKEY&recipient=447xxxxxxxxx&originator=SENDERID
&messagedata=MESSAGE -
https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage&apikey=APIKEY&originator=SENDERID&recipient=447xxxxxxxxx;447xxxxxxxxx&messagedata=MESSAGE
-
<form action=https://apikey.faretext-api.co.uk:9443/apikey method=post><br>
action: <input type=text name=action value=sendmessage><br>
apikey: <input type=text name=username value=APIKEY><br>
originator: <input type=text name=originator value=SENDERID><br>
recipient: <input type=text name=recipient value=447xxxxxxxxx><br>
messagedata: <input type=text name=messagedata value=’MESSAGE’><br>
<input type=submit value=OK>
</form> -
<form action=https://apikey.faretext-api.co.uk:9443/apikey method=post><br>
action: <input type=text name=action value=sendmessage><br>
apikey: <input type=text name=username value=APIKEY><br>
originator: <input type=text name=originator value=SENDERID><br>
recipient: <input type=text name=recipient value=447xxxxxxxxx;447xxxxxxxxx><br>
messagedata: <input type=text name=messagedata value=’MESSAGE‘><br>
<input type=submit value=OK>
</form>
Whatever your language, we’ll get you texting.
For simple but effective integration, identify your preferred programming language in the list below and expand. Choose between a GET or POST request. Then copy the example code, replacing the required fields with your issued API-key and personalised message details, then paste directly into your software, application or website to test.
Mandatory and optional parameters can be viewed by clicking the ‘show parameters’ button.
-
ASP
-
<% address = "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage" apikey = "your_apikey" originator = "your_originator/senderid" messagedata = "Hello this is a test from Faretext" messagedata = Server.urlencode(messagedata) recipient = "telephone_number" url = address & "&apikey=" & apikey & "&originator=" & originator & "&messagedata=" & messagedata & "&recipient=" & recipient set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") xmlhttp.open "GET", url, false xmlhttp.send "" msg = xmlhttp.responseText response.write(msg) set xmlhttp = nothing %>
-
<% address = "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage" apikey = "your_apikey" originator = "your_originator/senderid" messagedata = "Hello this is a test from Faretext" messagedata = Server.urlencode(messagedata) recipient = "telephone_number" url = address & "&apikey=" & apikey & "&originator=" & originator & "&messagedata=" & messagedata & "&recipient=" & recipient set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") xmlhttp.open "POST", url, false xmlhttp.send "" msg = xmlhttp.responseText response.write(msg) set xmlhttp = nothing %>
-
-
ASP.NET
-
<%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %>
-
<%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %>
-
-
C#
-
using System; using System.Collections.Generic; using System.Net; using System.Collections.Specialized; namespace send { class send { public string send() { String MessageData = HttpUtility.UrlEncode("Hello this is a test from Faretext"); using (var wb = new WebClient()) { byte[] response = wb.UploadValues("https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage", new NameValueCollection() { {"ApiKey" , "your_apikey"}, {"Originator" , "your_originator/senderid"} {"Recipient" , "telephone_number"}, {"MessageData" , MessageData}, }); string result = System.Text.Encoding.UTF8.GetString(response); return result; } } } }
-
using System; using System.Collections.Generic; using System.Net; using System.Collections.Specialized; using System.IO; namespace send { class send { public string send() { String result; string ApiKey = "your_apikey; string Originator = "your_originator/senderid"; string Recipient = "telephone_number"; string MessageData = "Hello this is a test from Faretext"; String url = “https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage&ApiKey” + ApiKey + "&Originator=" + Originator + "&Recipient=" + Recipient + "&MessageData=" + MessageData; StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentLength = Encoding.UTF8.GetByteCount(url); objRequest.ContentType = "application/x-www-form-urlencoded"; try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(url); } catch (Exception e) { return e.Message; } finally { myWriter.Close(); } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { result = sr.ReadToEnd(); sr.Close(); } return result; } } }
-
-
Delphi
-
function Send(ApiKey, Originator, Recipient, MessageData: String):string; const URL = 'https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage&ApiKey=%s&Originator=%s&Recipient=%s&MessageData=%s'; ResponseSize = 1024; var hSession, hURL: HInternet; Request: String;
ResponseLength: Cardinal; begin hSession := InternetOpen('DrBob42', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); try Request := Format(URL,[Username,Password,Originator,Recipient,HttpEncode(MessageData)]); hURL := InternetOpenURL(hSession, PChar(Request), nil, 0,0,0); try SetLength(Result, ResponseSize); InternetReadFile(hURL, PChar(Result), ResponseSize, ResponseLength); SetLength(Result, ResponseLength) finally InternetCloseHandle(hURL) end finally InternetCloseHandle(hSession) end end;
-
function send(const Url: string): string; var NetHandle: HINTERNET; UrlHandle: HINTERNET; Buffer: array[0..1024] of Char; BytesRead: dWord; begin Result := ''; NetHandle := InternetOpen('Delphi 5.x', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
if Assigned(NetHandle) then begin UrlHandle := InternetOpenUrl(NetHandle, PChar(Url), nil, 0, INTERNET_FLAG_RELOAD, 0);
if Assigned(UrlHandle) then { UrlHandle valid? Proceed with download } begin FillChar(Buffer, SizeOf(Buffer), 0); repeat Result := Result + Buffer; FillChar(Buffer, SizeOf(Buffer), 0); InternetReadFile(UrlHandle, @Buffer, SizeOf(Buffer), BytesRead); until BytesRead = 0; InternetCloseHandle(UrlHandle); end else { UrlHandle is not valid. Raise an exception. } raise Exception.CreateFmt('Error: Cannot open URL %s', [Url]);
InternetCloseHandle(NetHandle); end else { NetHandle is not valid. Raise an exception } raise Exception.Create('Error:'); end;
url := 'https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage' + '&ApiKey=your_apikey' +'&Originator=your_originator/senderid' + '&Recipient=telephone_number' + '&MessageData=Hello+this+is+a+test+from+Faretext'; send(url);
-
-
Java
-
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; public class send { public String send() { try { String ApiKey = "&ApiKey=" + URLEncoder.encode("your_apikey", "UTF-8"); String Originator = "&Originator=" + URLEncoder.encode("your_originator/senderid", "UTF-8"); String Recipient = "&Recipient=" + URLEncoder.encode("telephone_number", "UTF-8"); String MessageData = "&MessageData=" + URLEncoder.encode("Hello this is a test from Faretext", "UTF-8"); String data = "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage " + ApiKey + Originator + Recipient + MessageData; URL url = new URL(data); URLConnection conn = url.openConnection(); conn.setDoOutput(true); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; String sResult=""; while ((line = rd.readLine()) != null) { sResult=sResult+line+" "; } rd.close(); return sResult; } catch (Exception e) { System.out.println("Error:"+e); return "Error:"+e; } } }
-
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; public class send { public String send() { try { String ApiKey = "&ApiKey=" + "your_apikey"; String Originator = "&Originator=" + "your_originator/senderid"; String Recipient = "&Recipient=" + "telephone_number"; String MessageData = "&MessageData=" + "Hello this is a test from Faretext"; HttpURLConnection conn = (HttpURLConnection) new URL("https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage").openConnection(); String data = Username + Password + Originator + Recipient + MessageData; conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Length", Integer.toString(data.length())); conn.getOutputStream().write(data.getBytes("UTF-8")); final BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); final StringBuffer stringBuffer = new StringBuffer(); String line; while ((line = rd.readLine()) != null) { stringBuffer.append(line); } rd.close(); return stringBuffer.toString(); } catch (Exception e) { System.out.println("Error"+e); return "Error"+e; } } }
-
-
Perl
-
use LWP::Simple; my $ApiKey = "&ApiKey=" . 'your_apikey'; my $Originator = "&Orginator=" . "your_originator/senderid"; my $Recipient = "&Recipient=" . "telephone_number"; my $MessageData = "&MessageData=" . "Hello+this+is+a+test+from+Faretext"; my $String = join "", "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage", $ApiKey, $Originator, $Recipient, $MessageData; my $URL = get($String); print "$URL";
-
use strict; use LWP::UserAgent; use HTTP::Request::Common; my $ApiKey = "&ApiKey=" . 'your_apikey'; my $Originator = "&Orginator=" . "your_originator/senderid"; my $Recipient = "&Recipient=" . "telephone_number"; my $MessageData = "&MessageData=" . "Hello this is a test from Faretext"; my $send = LWP::UserAgent->new(); my $url = $send->request ( POST 'https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage', Content_Type => 'application/x-www-form-urlencoded', Content => [ 'ApiKey' => $ApiKey, 'Password' => $Password, 'Originator' => $Originator, 'Recipient' => $Recipient, 'MessageData' => $MessageData ] ); if ($url->is_error) { die "HTTP: Error"; } print "Response:nn" . $url->content . "nn";
-
-
PHP
-
<?php $ApiKey = "your_apikey"; $Originator = urlencode('your_originator/senderid'); $Recipient = urlencode('telephone_number'); $MessageData = rawurlencode('Hello this is a test from Faretext'); $smsdata = array('&ApiKey=' . $ApiKey. '&Originator=' . $Originator. "&Recipient=" . $Recipient. "&MessageData=" . $MessageData); $ch = curl_init('https://api.faretext.co.uk:9443/apikey?action=sendmessage' . $smsdata); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); echo $response; ?>
-
<?php $ApiKey = "your_apikey"; $Originator = urlencode('your_originator/senderid'); $Recipient = urlencode('telephone_number'); $MessageData = rawurlencode('Hello this is a test from Faretext'); $smsdata = array('&ApiKey=' . $ApiKey. '&Originator=' . $Originator. "&Recipient=" . $Recipient. "&MessageData=" . $MessageData); $ch = curl_init('https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $smsdata); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); echo $response; ?>
-
-
Python
-
import urllib.request import urllib.parse def send(ApiKey, Originator, Recipient, MessageData): params = {'ApiKey': your_apikey, 'Originator': your_originator/senderid, 'Recipient' : telephone_number, 'MessageData': MessageData} f = urllib.request.urlopen('https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage' + urllib.parse.urlencode(params)) return (f.read(), f.code) resp, code = send('your_apikey', 'your_originator/senderid', 'telephone_number', 'Hello this is a test from Faretext') print (resp)
-
import urllib.request import urllib.parse def send(ApiKey, Originator, Recipient, MessageData): data = urllib.parse.urlencode({'ApiKey': your_apikey, 'Originator': your_originator/senderid, 'Recipient': telephone_number, 'MessageData': MessageData}) data = data.encode('utf-8') request = urllib.request.Request("https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage") f = urllib.request.urlopen(request, data) fr = f.read() return(fr) resp = send('your_apikey', 'your_originator/senderid', 'telephone_number', 'Hello this is a test from Faretext') print (resp)
-
-
Ruby
-
require "rubygems" require "net/https" require "uri" require "json" ApiKey = "your_apikey" Originator = "your_originator/senderid" Recipient = "telephone_number" MessageData = "Hello this is a test from Faretext" requested_url = 'https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage' + "&ApiKey=" + ApiKey + "&Originator=" + Originator + "&Recipient=" + Recipient "&MessageData=" + URI.escape(MessageData) uri = URI.parse(requested_url) http = Net::HTTP.start(uri.host, uri.port) request = Net::HTTP::Get.new(uri.request_uri) res = http.request(request) response = JSON.parse(res.body) puts (response)
-
require "rubygems" require "net/https" require "uri" require "json" requested_url = 'https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage' uri = URI.parse(requested_url) http = Net::HTTP.start(uri.host, uri.port) request = Net::HTTP::Get.new(uri.request_uri) res = Net::HTTP.post_form(uri, 'ApiKey' => 'your_apikey', 'Originator' => 'your_originator/senderid', 'Recipient' => 'telephone_number', 'MessageData' => 'Hello this is a test from Faretext') response = JSON.parse(res.body) puts (response)
-
-
VBA
-
Public Sub Send() Dim ApiKey As String ApiKey = "&ApiKey=" + "your_apikey" Dim Originator As String Originator = "&Originator=" + "your_originator/senderid" Dim Recipient As String Recipient = "&Recipient=" + "telephone_number" MessageData As String MessageData = "&MessageData=" + "Hello this is a test from Faretext" Set MyRequest = CreateObject("WinHttp.WinHttpRequest.5.1") MyRequest.Open "GET", "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage" + ApiKey + Originator + Recipient + MessageData MyRequest.Send MsgBox MyRequest.ResponseText End Sub
-
Public Sub Send() Dim Apikey As String Dim Originator As String Dim Recipient As String Dim MessageData As String Dim URL As String Dim postData As String Dim winHttpReq As Object ApiKey = "your_apikey" Originator = "your_originator/senderid" Recipient = "telephone_number" MessageData = "Hello this is a test from Faretext" URL = "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage" Set winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1") postData = "&ApiKey=" + ApiKey + "&Originator=" + Originator "&Recipient=" + Recipient + "&MessageData=" + MessageData winHttpReq.Open "POST", myURL, False winHttpReq.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded" winHttpReq.Send (postData) SendSMS = winHttpReq.responseText End Sub
-
-
VBA.NET
-
Imports System.Net Imports System.Web Imports System.Collections.Specialized Imports System.IO Imports System.Text Public Class send Public Function send() Dim ApiKey = "your_apikey" Dim Originator = "your_originator/senderid" Dim Recipient = "telephone_number" Dim Messagedata = "Hello this is a test from Faretext" Dim strGet As String Dim url As String = "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage" strGet = url + "&ApiKey=" + ApiKey _ + "&Originator=" + Originator _ + "&Recipient=" + Recipient _ + "&MessageData=" + WebUtility.UrlEncode(MessageData) Dim webClient As New System.Net.WebClient Dim result As String = webClient.DownloadString(strGet) Console.WriteLine(result) Return result End Function End Class
-
Imports System.Web Imports System.IO Imports System.Net Imports System.Text Imports System.Resources Public Class send Public Function send() Dim ApiKey = "your_apikey" Dim Originator = "your_originator/senderid" Dim Recipient = "telephone_number" Dim Messagedata = "Hello this is a test from Faretext" Dim strPost As String Dim url As String = "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage" strPost = url + "&ApiKey=" + ApiKey _ + "&Originator=" + Originator _ + "&Recipient=" + Recipient _ + "&MessageData=" + WebUtility.UrlEncode(MessageData) Dim request As WebRequest = WebRequest.Create(strPost) request.Method = "POST" Dim byteArray As Byte() = Encoding.UTF8.GetBytes(strPost) request.ContentType = "application/x-www-form-urlencoded" request.ContentLength = byteArray.Length Dim dataStream As Stream = request.GetRequestStream() dataStream.Write(byteArray, 0, byteArray.Length) dataStream.Close() Dim response As WebResponse = request.GetResponse() dataStream = response.GetResponseStream() Dim reader As New StreamReader(dataStream) Dim responseFromServer As String = reader.ReadToEnd() Console.WriteLine(responseFromServer) Console.ReadLine() reader.Close() dataStream.Close() response.Close() If responseFromServer.Length > 0 Then Return responseFromServer Else Return CType(response, HttpWebResponse).StatusDescription End If End Function End Class
-
-
VB6
-
Private Sub send() Dim DataToSend As String Dim objXML As Object Dim Messagedata As String Dim ApiKey As String Dim Recipient As String Dim Originator As String Dim URL As String ApiKey = "your_apikey"; Originator = "your_originator/senderid" Recipient = "telephone_number" URL = "http://apikey.faretext-api.co.uk:9501/apikey?action=sendmessage" Messagedata = URLEncode("Hello this is a test from Faretext") Set objXML = CreateObject("Microsoft.XMLHTTP") objXML.Open "POST", URL , False objXML.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objXML.send "&ApiKey=" + ApiKey + "&Recipient=" + Recipient + "&Messagedata=" + Messagedata + "&Originator=" + Originator If Len(objXML.responseText) > 0 Then MsgBox objXML.responseText End If End Sub Function URLEncode(ByVal Text As String) As String Dim i As Integer Dim acode As Integer Dim char As String URLEncode = Text For i = Len(URLEncode) To 1 Step -1 acode = Asc(Mid$(URLEncode, i, 1)) Select Case acode Case 48 To 57, 65 To 90, 97 To 122 Case 32 Mid$(URLEncode, i, 1) = "+" Case Else URLEncode = Left$(URLEncode, i - 1) & "%" & Hex$(acode) & Mid$ _ (URLEncode, i + 1) End Select Next End Function
-
Private Sub send() Dim DataToSend As String Dim objXML As Object Dim Messagedata As String Dim ApiKey As String Dim Recipient As String Dim Originator As String Dim URL As String ApiKey = "your_apikey"; Originator = "your_originator/senderid" Recipient = "telephone_number" URL = "http://apikey.faretext-api.co.uk:9501/apikey?action=sendmessage" Messagedata = URLEncode("Hello this is a test from Faretext") Set objXML = CreateObject("Microsoft.XMLHTTP") objXML.Open "POST", URL , False objXML.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objXML.send "&ApiKey=" + ApiKey + "&Recipient=" + Recipient + "&Messagedata=" + Messagedata + "&Originator=" + Originator If Len(objXML.responseText) > 0 Then MsgBox objXML.responseText End If End Sub Function URLEncode(ByVal Text As String) As String Dim i As Integer Dim acode As Integer Dim char As String URLEncode = Text For i = Len(URLEncode) To 1 Step -1 acode = Asc(Mid$(URLEncode, i, 1)) Select Case acode Case 48 To 57, 65 To 90, 97 To 122 Case 32 Mid$(URLEncode, i, 1) = "+" Case Else URLEncode = Left$(URLEncode, i - 1) & "%" & Hex$(acode) & Mid$ _ (URLEncode, i + 1) End Select Next End Function
-
-
Mandatory Parameters
ParameterDescriptionPossible valuesExampleactionSpecifies the HTTPs API commandsendmessageaction=sendmessageapikeySpecifies the apikey. The apikey parameters are used to authenticate the user. When you send a message it will be sent in the name of the authenticated user.string valuerecipientSpecifies the recipient phone number. The message will be sent to this telephone number. The telephone number can be specified in local number format (e.g.077421234567), or in international number format (e.g.+4477421234567). More then one recipient addresses can be separated by a colon (e.g.: +4477421234567,+447422222222) The value must be urlencoded.string value, maximum length is 32768 charactersmessagedata=MESSAGEmessagedataSpecifies the text or the data of the SMS message. The value must be encoded in UTF8 and must be urlencoded.string value, maximum length is 32768 charactersmessagedata=MESSAGEOptional Parameters
ParameterDescriptionPossible valuesExampleoriginatorSpecifies the sender address. This information will be displayed on the mobile phone, that receives the message. This is the sender address. This can be a telephone number, a short code or an alphanumeric sender address. The telephone number must can be formatted in local number format (e.g.077421234567), or in international number format (e.g.+4477421234567). If you use an alphanumeric sender address (e.g.FareText), the characters must be encoded in UTF8 and the value must be urlencoded.string value, maximum length is 16 characters. NOTE: UK Network support up to 11 characters.originator=SENDERIDsendondateSpecifies the date and time, when the message should be sent. The value must use the following date format: YYYY-MM-DD hh:mm:ss. The value must be url encoded.date value in YYYY-MM-DD hh:mm:ss formatsendondate=2020-12-31%2021:00:00 - Example will send a message on 31st December 2020 at 21:00responseformatAfter the gateway submits the SMS message, the gateway will return a web page indicating that the message was submitted successfully. The content of the webpage is formatted according to the responseformat parameter. You can have html text response to make it easy for humans to read it or you can have xml format to make it easy for software to process the response.xml (default) html urlencodedresponseformat=xmlreporturlYou can setup a webpage to process information about “delivered to network” and “delivered to handset”events. If you specify an URL in the reporturl parameter, your webpage will be called when these events happen. The value of the URL you specify in the reporturl parameter must be urlencoded. The URL you specify can contain keywords that will be replaced to state information corresponding to the submitted message. More information about possible keywords can be found in the “Submit URL keywords” guide. Please also note, that if you want the reporturl parameter to work, you must create a “HTTPs server user” account and use it’s username and password. The “Standard user” account does not support this option.string value, maximum length is 1024 charactersreporturl=http://www.Domain. com/SMS.php? reporttype= $reporttype&messageid= $messageid) Note: this is the urlencoded version of the following URL. Before this URL is called by the SMS gateway, the $reporttype and $messageid parameters will be replaced to the appropriate values: reporturl=http%3A%2F%2F www.domain.com %2Fsms.php%3Freporttype %3D%24reporttype %26messageid%3D% 24messageid will be called as: http://www.Domain.com/SMS. php?reporttype=deliveredtohandset &messageid=e99549d4-65f7- 435d-ba19-de6b851801ce
Can’t see your programming language? Please get in touch by using the form at the bottom of the page.