Message » Send

Sends a text or unicode message.


Sample Code


Click on your desired language to get the sample code in your desired language.


CURL *hnd = curl_easy_init();

curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); curl_easy_setopt(hnd, CURLOPT_URL, "https://www.thetexting.com/rest/sms/json/message/send");

struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "content-type: application/x-www-form-urlencoded"); headers = curl_slist_append(headers, "cache-control: no-cache"); curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);

curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "api_secret=your_api_secret&api_key=your_api_Key&from=test&to=1234567890&text=Sample%20Message%20Text&type=text");

CURLcode ret = curl_easy_perform(hnd);

var client = new RestClient("https://www.thetexting.com/rest/sms/json/message/send");
var request = new RestRequest(Method.POST); request.AddHeader("content-type", "application/x-www-form-urlencoded"); request.AddHeader("cache-control", "no-cache"); request.AddParameter("application/x-www-form-urlencoded", "api_secret=your_api_secret&api_key=your_api_Key&from=test&to=1234567890&text=Sample%20Message%20Text&type=text", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://www.thetexting.com/rest/sms/json/message/send"

payload := strings.NewReader("api_secret=your_api_secret&api_key=your_api_Key&from=test&to=1234567890&text=Sample%20Message%20Text&type=text")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("cache-control", "no-cache") req.Header.Add("content-type", "application/x-www-form-urlencoded")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "api_secret=your_api_secret&api_key=your_api_Key&from=test&to=1234567890&text=Sample%20Message%20Text&type=text");
Request request = new Request.Builder() .url("https://www.thetexting.com/rest/sms/json/message/send") .post(body) .addHeader("cache-control", "no-cache") .addHeader("content-type", "application/x-www-form-urlencoded") .build();

Response response = client.newCall(request).execute();

HttpResponse response = Unirest.post("https://www.thetexting.com/rest/sms/json/message/send") .header("cache-control", "no-cache") .header("content-type", "application/x-www-form-urlencoded") .body("api_secret=your_api_secret&api_key=your_api_Key&from=test&to=1234567890&text=Sample%20Message%20Text&type=text") .asString();

var settings = { "async": true, "crossDomain": true, "url": "https://www.thetexting.com/rest/sms/json/message/send", "method": "POST", "headers": { "cache-control": "no-cache", "content-type": "application/x-www-form-urlencoded" }, "data": { "api_secret": "your_api_secret", "api_key": "your_api_Key", "from": "987654321", "to": "123456789", "text": "Sample Message Text", "type": "text" } }

$.ajax(settings).done(function (response) { console.log(response); });

var data = "api_secret=your_api_secret&api_key=your_api_Key&from=test&to=1234567890&text=Sample%20Message%20Text&type=text";

var xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === 4) { console.log(this.responseText); } });

xhr.open("POST", "https://www.thetexting.com/rest/sms/json/message/send"); xhr.setRequestHeader("cache-control", "no-cache"); xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");

xhr.send(data);

var qs = require("querystring"); var http = require("https");

var options = { "method": "POST", "hostname": "www.thetexting.com", "port": null, "path": "/rest/sms/json/message/send", "headers": { "cache-control": "no-cache", "content-type": "application/x-www-form-urlencoded" } };

var req = http.request(options, function (res) { var chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.write(qs.stringify({ api_secret: 'your_api_secret', api_key: 'your_api_Key', from: '987654321', to: '123456789', text: 'Sample Message Text', type: 'text' })); req.end();

var request = require("request");

var options = { method: 'POST', url: 'https://www.thetexting.com/rest/sms/json/message/send', headers: { 'content-type': 'application/x-www-form-urlencoded', 'cache-control': 'no-cache' }, form: { api_secret: 'your_api_secret', api_key: 'your_api_Key', from: '987654321', to: '123456789', text: 'Sample Message Text', type: 'text' } };

request(options, function (error, response, body) { if (error) throw new Error(error);

console.log(body); });

var unirest = require("unirest");

var req = unirest("POST", "https://www.thetexting.com/rest/sms/json/message/send");

req.headers({ "content-type": "application/x-www-form-urlencoded", "cache-control": "no-cache" });

req.form({ "api_secret": "your_api_secret", "api_key": "your_api_Key", "from": "987654321", "to": "123456789", "text": "Sample Message Text", "type": "text" });

req.end(function (res) { if (res.error) throw new Error(res.error);

console.log(res.body); });

#import

NSDictionary *headers = @{ @"cache-control": @"no-cache", @"content-type": @"application/x-www-form-urlencoded" };

NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"api_secret=your_api_secret" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&api_key=your_api_Key" dataUsingEncoding:NSUTF8StringEncoding]]; [postData appendData:[@"&from=test" dataUsingEncoding:NSUTF8StringEncoding]]; [postData appendData:[@"&to=1234567890" dataUsingEncoding:NSUTF8StringEncoding]]; [postData appendData:[@"&text=Sample Message Text" dataUsingEncoding:NSUTF8StringEncoding]]; [postData appendData:[@"&type=text" dataUsingEncoding:NSUTF8StringEncoding]];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://www.thetexting.com/rest/sms/json/message/send"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0];
[request setHTTPMethod:@"POST"]; [request setAllHTTPHeaderFields:headers]; [request setHTTPBody:postData];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) { NSLog(@"%@", error); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSLog(@"%@", httpResponse); } }];
[dataTask resume];

open Cohttp_lwt_unix open Cohttp open Lwt

let uri = Uri.of_string "https://www.thetexting.com/rest/sms/json/message/send" in let headers = Header.init () |> fun h -> Header.add h "cache-control" "no-cache" |> fun h -> Header.add h "content-type" "application/x-www-form-urlencoded" in let body = Cohttp_lwt_body.of_string "api_secret=your_api_secret&api_key=your_api_Key&from=test&to=1234567890&text=Sample%20Message%20Text&type=text" in

Client.call ~headers ~body `POST uri >>= fun (res, body_stream) -> (* Do stuff with the result *)

<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://www.thetexting.com/rest/sms/json/message/send", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "" CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "api_secret=your_api_secret&api_key=your_api_Key&from=test&to=1234567890&text=Sample%20Message%20Text&type=text", CURLOPT_HTTPHEADER => array( "cache-control: no-cache", "content-type: application/x-www-form-urlencoded", ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }


?>

<?php

$request = new HttpRequest(); $request->setUrl('https://www.thetexting.com/rest/sms/json/message/send'); $request->setMethod(HTTP_METH_POST);

$request->setHeaders(array( 'content-type' => 'application/x-www-form-urlencoded', 'cache-control' => 'no-cache' ));

$request->setContentType('application/x-www-form-urlencoded'); $request->setPostFields(array( 'api_secret' => 'your_api_secret', 'api_key' => 'your_api_Key', 'from' => '987654321', 'to' => '123456789', 'text' => 'Sample Message Text', 'type' => 'text' ));

try {
$response = $request->send();

echo $response->getBody(); } catch (HttpException $ex) { echo $ex; }


?>

<?php

$client = new http\Client; $request = new http\Client\Request;

$body = new http\Message\Body; $body->append(new http\QueryString(array( 'api_secret' => 'your_api_secret', 'api_key' => 'your_api_Key', 'from' => '987654321', 'to' => '123456789', 'text' => 'Sample Message Text', 'type' => 'text' )));

$request->setRequestUrl('https://www.thetexting.com/rest/sms/json/message/send'); $request->setRequestMethod('POST'); $request->setBody($body);

$request->setHeaders(array( 'content-type' => 'application/x-www-form-urlencoded', 'cache-control' => 'no-cache' ));

$client->enqueue($request)->send(); $response = $client->getResponse();

echo $response->getBody();


?>

import http.client

conn = http.client.HTTPSConnection("www.thetexting.com")

payload = "api_secret=your_api_secret&api_key=your_api_Key&from=test&to=1234567890&text=Sample%20Message%20Text&type=text"

headers = { 'cache-control': "no-cache", 'content-type': "application/x-www-form-urlencoded" }

conn.request("POST", "/rest/sms/json/message/send", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

import requests

url = "https://www.thetexting.com/rest/sms/json/message/send"

payload = "api_secret=your_api_secret&api_key=your_api_Key&from=test&to=1234567890&text=Sample%20Message%20Text&type=text" headers = { 'cache-control': "no-cache", 'content-type': "application/x-www-form-urlencoded" }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)

require 'uri' require 'net/http'

url = URI("https://www.thetexting.com/rest/sms/json/message/send")

http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url) request["cache-control"] = 'no-cache' request["content-type"] = 'application/x-www-form-urlencoded' request.body = "api_secret=your_api_secret&api_key=your_api_Key&from=test&to=1234567890&text=Sample%20Message%20Text&type=text"

response = http.request(request) puts response.read_body

curl --request POST \ --url https://www.thetexting.com/rest/sms/json/message/send \ --header 'cache-control: no-cache' \ --header 'content-type: application/x-www-form-urlencoded' \ --data 'api_secret=your_api_secret&api_key=your_api_Key&from=test&to=1234567890&text=Sample%20Message%20Text&type=text'

http --form POST https://www.thetexting.com/rest/sms/json/message/send \ cache-control:no-cache \ content-type:application/x-www-form-urlencoded \ api_secret=your_api_secret \ api_key=your_api_Key \ from=test \ to=1234567890 \ text='Sample Message Text' \ type=text

wget --quiet \ --method POST \ --header 'cache-control: no-cache' \ --header 'content-type: application/x-www-form-urlencoded' \ --body-data 'api_secret=your_api_secret&api_key=your_api_Key&from=test&to=1234567890&text=Sample%20Message%20Text&type=text' \ --output-document \ - https://www.thetexting.com/rest/sms/json/message/send

import Foundation

let headers = [ "cache-control": "no-cache", "content-type": "application/x-www-form-urlencoded" ]

var postData = NSMutableData(data: "api_secret=your_api_secret".dataUsingEncoding(NSUTF8StringEncoding)!) postData.appendData("&api_key=your_api_Key".dataUsingEncoding(NSUTF8StringEncoding)!) postData.appendData("&from=test".dataUsingEncoding(NSUTF8StringEncoding)!) postData.appendData("&to=1234567890".dataUsingEncoding(NSUTF8StringEncoding)!) postData.appendData("&text=Sample Message Text".dataUsingEncoding(NSUTF8StringEncoding)!) postData.appendData("&type=text".dataUsingEncoding(NSUTF8StringEncoding)!)

var request = NSMutableURLRequest(URL: NSURL(string: "https://www.thetexting.com/rest/sms/json/message/send")!, cachePolicy: .UseProtocolCachePolicy,timeoutInterval: 10.0) request.HTTPMethod = "POST" request.allHTTPHeaderFields = headers request.HTTPBody = postData

let session = NSURLSession.sharedSession() let dataTask = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in if (error != nil) { println(error) } else { let httpResponse = response as? NSHTTPURLResponse println(httpResponse) } })

dataTask.resume()

TheTexting