Version No 3.2.0

Introduction


Send messages directly from your web application with the SMS API. The main advantage of our system is its simplicity of implementation.


SMS API Service


Our service supports Easily SMS-enable your website, application or customer relationship management platform with our REST FULL API.
A programmatic linking through the API is an option that enables you to create a programmatic linking process between your account in messages service with any external application , such as an Internet website, a mobile application, an accounting program, a customer management program etc. The SMS system supports all programming languages to complete the programmatic linking process such as PHP - JAVA - C++ - ASP.
You can simply link your account by going to your account after logging in to the direct linking option API, and the system will guide you to the linking way easily. Is there an additional cost to request a direct linking ?
Of course there will be no additional cost for the programmatic linking process . Also the technical support team will be available to help you set up the direct linking and fully equipped it for you.

Requirements


To be able to use the API service, you must have some conditions within your account, so that the connection with the messaging service is correct and without any problem
These conditions are

Active account So that your account is active in the messaging service and your control panel is fully activated
The balance You must have a message balance in your account in order to be able to use API
Sender ID Your account must have a fully verified Sender ID

Get started


Get started with the API of your text messaging service provider Log in to your account
And orientation from the main menu - My Account - API Settings


You will see your account information in order to start using the service.

Sending SMS POST


URL addresses that you need to use to connect to SMS API are:

URL Adresses

https://www.turkeysms.com.tr/api/v3/gonder/add-content

Parameter

							
$title    = '';
$api_key  = '';
$text	  = '';
$sentto	  = '';
$report   = '';
$sms_lang = '';
$response_type = '';
							
							

Parameter Description

$title varchar Write here your Sender ID as it is in your account.
$api_key varchar Your API key on your account will be placed here
$text text The message text
$sentto int Recipient's mobile phone number
$report int Option to display the details of the sending process if the value is 1, the report appears, or 0 for cancellation
$sms_lang int This parameter describes the encoding of the message text. UTF-8 is set as default
$response_type int Response is sending JSON or Array

Examples of responses If the option to show the report is enabled
Response code

Call Back Reports


Array
(
    [result] => true
    [sms_id] => 1000007721
    [number_of_sms] => 1
    [result_code] => TS-1024
    [result_message] => The message was sent successfully
    [sms_lang] => Arabic
    [country] => Turkey-TR
)
							

Call Back Description

result The result of the operation, if successful, appears true, and if the transmission fails, it appears false
sms_id Message ID. Length of this parameter in each request may vary
number_of_sms Number of used credits
result_code Status code, list of codes can be find in Response code
result_message The message of the sent operation .. SMS appears to you in the event of success or failure
sms_lang The content of the message you sent appears in any language
country The name of the country to which the message was sent

Sending SMS GET


How to send a message through the API in GET format

The variables sent through the link are - variables and options as I mentioned above

							
https://turkeysms.com.tr/api/v3/get/get.php?api_key=API_KEY_HERE&mobile=MOBILE_HERE&title=TITLE_HERE&text=SMS_TEXT_HERE&report=1&lang=2&response_type=json
							
							

Response code


When sending via direct connection api, the server will send you a response to the process in the form of a code
These codes explain to you the result of the operation that you have performed

Response code

TS-1024 Message sent successfully
TS-1025 The mobile number has not been entered. The phone number is empty
TS-1026 Message text is empty .. No message text has been written
TS-1027 There is insufficient balance in your account
TS-1028 Sender ID is not active for your account
TS-1029 The Sender ID does not exist .. Please make sure you type correctly
TS-1030 Your account is inactive with the SMS service provider
TS-1031 The api-key is invalid
TS-1032 The number to which the message is sent is international outside Turkey. Your account is not activated for international SMS
TS-1033 The data sent through the link is incorrect
TS-1034 The mobile number to which the message was sent is invalid

Checking the validity of the code


Verification of authorization code could be made by POST request to API with two parameters, recipient mobile phone number

							
https://turkeysms.com.tr/api/v3/sms-durumu/sms_durumu.php?api_key=API_KEY_HERE&sms_id=SMS_ID_HERE&response_type=php							
							
							

The variables sent through the link are

							
$api_key  = '';
$sms_id	  = '';
$response_type = '';
							
							

Parameter Description

api_key$ varchar Your API key on your account will be placed here
sms_id$ int Message ID
response_type$ int Response is sending JSON or PHP

Call Back Reports

Example Response


Array
(
    [result] => true
    [sender_id] => SenderID
    [date_of_sending] => 2021-01-01
    [time_of_sending] => 13:10:00
    [sms_status] => Number received the message
    [sms_status_code] => TS-1024
    [sms_balance] => 1 SMS
    [operator] => Turkcell
)
							

Parameter Description

result The result of the operation, if successful, appears true, and if the transmission fails, it appears false
sender_id Message ID. Length of this parameter in each request may vary
date_of_sending The date the message was sent
time_of_sending The time the message was sent
sms_status Message Status - Delivered - Not delivered - Number out of coverage
sms_status_code Status Code
sms_balance Number of used credits
operator The name of the company to which the number belongs

International SMS


The term ( international messages) means messages that are sent outside the borders of the Turkish Republic.
They include all the numbers that (do not start) with the international code (+90-0090).
Turkey SMS service enables you to SMS message through your account to any country in the world. But you have to charge your balance with an international account so you can send to any country in the world.
The price of the message varies from one country to another and the arrival time of the international message varies from one country to another as well. In order to be able to send internationally, you must contact the Technical Support Center of Turkey SMS service to activate your account so that you can send internationally.

How do I send an international message through api?

The same way to send the local message inside Turkey .. With the same link and with all options
But you must recharge your account with an international balance
And the number sent to him must be written in the international code

Example


Text messaging system supports all programming languages to complete the programming process like this

PHP Java JavaScript NodeJS Python CSharp C(LibCURL) Go ObjectiveC Ruby Swift

PHP

function sendRequest($site, $data)
{
    $json = json_encode($data);
    $ch = curl_init($site);
    $header = array('Content-Type: application/json');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}
$api_key  = '';
$title    = '';
$text	  = '';
$sentto	  = '';

$body = array("api_key" => $api_key, "title"=>$title, "text"=>$text,"sentto"=>$sentto);
$result = sendRequest('https://www.turkeysms.com.tr/api/v3/gonder/add-content', $body);
//http://www.lalit.org/lab/convert-xml-to-array-in-php-xml2array/

JAVA

Unirest.setTimeouts(0, 0);
HttpResponse response = Unirest.post("https://www.turkeysms.com.tr/api/v3/gonder/add-content")
.header("Content-Type", "application/json")
.body("{\"api_key\":\"API_KEY_HERE\",\"title\":\"SMS_TITLE_HERE\",\"text\":\"TEXT_SMS\",\"sentto\":\"90500000000\"}")
.asString();

JavaScript

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"api_key":"API_KEY_HERE","title":"SMS_TITLE_HERE","text":"TEXT_SMS","sentto":"90500000000"});

var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};

fetch("https://www.turkeysms.com.tr/api/v3/gonder/add-content", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

Python

import requests

url = "https://www.turkeysms.com.tr/api/v3/gonder/add-content"

payload = "{\"api_key\":\"API_KEY_HERE\",\"title\":\"SMS_TITLE_HERE\",\"text\":\"TEXT_SMS\",\"sentto\":\"90500000000\"}"
headers = {
  'Content-Type': 'application/json'
}

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

print(response.text.encode('utf8'))

Ruby

require "uri"
require "net/http"

url = URI("https://www.turkeysms.com.tr/api/v3/gonder/add-content")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request.body = "{\"api_key\":\"API_KEY_HERE\",\"title\":\"SMS_TITLE_HERE\",\"text\":\"TEXT_SMS\",\"sentto\":\"90500000000\"}"

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

CSharp

var client = new RestClient("https://www.turkeysms.com.tr/api/v3/gonder/add-content");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\"api_key\":\"API_KEY_HERE\",\"title\":\"SMS_TITLE_HERE\",\"text\":\"TEXT_SMS\",\"sentto\":\"90500000000\"}",  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

C(LibCURL)

CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
  curl_easy_setopt(curl, CURLOPT_URL, "https://www.turkeysms.com.tr/api/v3/gonder/add-content");
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
  struct curl_slist *headers = NULL;
  headers = curl_slist_append(headers, "Content-Type: application/json");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  const char *data = "{\"api_key\":\"API_KEY_HERE\",\"title\":\"SMS_TITLE_HERE\",\"text\":\"TEXT_SMS\",\"sentto\":\"90500000000\"}";
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
  res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);


NodeJS

var unirest = require('unirest');
var req = unirest('POST', 'https://www.turkeysms.com.tr/api/v3/gonder/add-content')
  .headers({
    'Content-Type': 'application/json'
  })
  .send(JSON.stringify({"api_key":"API_KEY_HERE","title":"SMS_TITLE_HERE","text":"TEXT_SMS","sentto":"90500000000"}))
  .end(function (res) { 
    if (res.error) throw new Error(res.error); 
    console.log(res.raw_body);
  });

ObjectiveC


#import  Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://www.turkeysms.com.tr/api/v3/gonder/add-content"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Content-Type": @"application/json"
};

[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\"api_key\":\"API_KEY_HERE\",\"title\":\"SMS_TITLE_HERE\",\"text\":\"TEXT_SMS\",\"sentto\":\"90500000000\"}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

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;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Go


package main
import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)
func main() {
  url := ""https://www.turkeysms.com.tr/api/v3/gonder/add-content"
  method := "POST"
  payload := strings.NewReader("{\"api_key\":\"API_KEY_HERE\",\"title\":\"SMS_TITLE_HERE\",\"text\":\"TEXT_SMS\",\"sentto\":\"90500000000\"}")
  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}

Swift

import Foundation

var semaphore = DispatchSemaphore (value: 0)

let parameters = "{\"api_key\":\"API_KEY_HERE\",\"title\":\"SMS_TITLE_HERE\",\"text\":\"TEXT_SMS\",\"sentto\":\"90500000000\"}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "https://www.turkeysms.com.tr/api/v3/gonder/add-content")!,timeoutInterval: Double.infinity)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
  semaphore.signal()
}

task.resume()
semaphore.wait()

SMS Libraries


You can download ready-made files in the programming language you want for your use

PHP File