В примерах для простоты мы описали только функцию отправки СМС. С полным функционалом нашего SMS шлюза вы можете ознакомиться в разделе API. Также, если вам требуется документация на каком-то другом языке и/или вам необходимо описание другой функции, пожалуйста, позвоните нам по телефону 8(800)100-18-64, напишите на нашу почту support@sms-boom.ru, в онлайн чате или закажите обратный звонок на сайте.

Доступны примеры на следующих языках (ссылки кликабельны) : PHP, Python, C#, Java и Ruby


Пример отправки СМС на PHP


                  
<?php

// Initialize cURL session
$ch = curl_init();

// Your API login credentials and message details
$login = 'your_login'; // replace with your login
$password = 'your_password'; // replace with your password
$phone = '+71234567890'; // replace with the recipient's phone number
$text = 'Your message text'; // replace with your message text

// API endpoint for sending messages
$url = "http://api.sms-boom.ru/messages/v2/send/";

// Create the URL with query parameters
$fullUrl = $url . "?phone=" . urlencode($phone) . "&text=" . urlencode($text);

// Set cURL options
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); // The request type is GET
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Authorization: Basic ' . base64_encode("$login:$password"), // Basic Auth header
    'Content-Type: application/json'
));

// Execute the cURL session and fetch the response
$response = curl_exec($ch);

// Check for cURL errors
if (curl_errno($ch)) {
    echo 'cURL error: ' . curl_error($ch);
} else {
    // Print the response from the server
    echo 'Response: ' . $response;
}

// Close cURL session
curl_close($ch);

?>


Пример отправки СМС на Python

import requests
from requests.auth import HTTPBasicAuth
import urllib.parse

# Your API login credentials and message details
login = 'your_login'  # replace with your login
password = 'your_password'  # replace with your password
phone = '+71234567890'  # replace with the recipient's phone number
text = 'Your message text'  # replace with your message text

# API endpoint for sending messages
url = "http://api.sms-boom.ru/messages/v2/send/"

# Create the URL with query parameters
full_url = f"{url}?phone={urllib.parse.quote(phone)}&text={urllib.parse.quote(text)}"

# Send the GET request and get the response
response = requests.get(full_url, auth=HTTPBasicAuth(login, password))

# Print the response status code and body
print('HTTP Status Code:', response.status_code)
print('Response Body:', response.text)


Пример отправки СМС на C#

using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        // Your API login credentials and message details
        string login = "your_login"; // replace with your login
        string password = "your_password"; // replace with your password
        string phone = "+71234567890"; // replace with the recipient's phone number
        string text = "Your message text"; // replace with your message text

        // API endpoint for sending messages
        string url = "http://api.sms-boom.ru/messages/v2/send/";

        // Create the URL with query parameters
        string fullUrl = $"{url}?phone={Uri.EscapeDataString(phone)}&text={Uri.EscapeDataString(text)}";

        using (HttpClient client = new HttpClient())
        {
            // Set Basic Authentication header
            var byteArray = Encoding.ASCII.GetBytes($"{login}:{password}");
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));

            // Set additional headers
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

            try
            {
                // Send the GET request and get the response
                HttpResponseMessage response = await client.GetAsync(fullUrl);
                string responseString = await response.Content.ReadAsStringAsync();

                // Print the response status code and body
                Console.WriteLine("HTTP Status Code: " + response.StatusCode);
                Console.WriteLine("Response Body: " + responseString);
            }
            catch (HttpRequestException e)
            {
                // Handle any errors here
                Console.WriteLine("Error: " + e.Message);
            }
        }
    }
}


Пример отправки СМС на Java

import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Base64;

public class SmsSender {
    public static void main(String[] args) {
        try {
            String login = "your_login";  // replace with your login
            String password = "your_password";  // replace with your password
            String phone = "+71234567890";  // replace with the recipient's phone number
            String text = "Your message text";  // replace with your message text

            // API endpoint for sending messages
            String urlString = "http://api.sms-boom.ru/messages/v2/send/";
            String queryParams = "?phone=" + java.net.URLEncoder.encode(phone, "UTF-8") + "&text=" + java.net.URLEncoder.encode(text, "UTF-8");
            
            URL url = new URL(urlString + queryParams);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            
            // Set the request method and headers
            connection.setRequestMethod("GET");
            String encoded = Base64.getEncoder().encodeToString((login + ":" + password).getBytes("UTF-8"));
            connection.setRequestProperty("Authorization", "Basic " + encoded);
            connection.setRequestProperty("Content-Type", "application/json");

            // Make the request and check the response code
            int responseCode = connection.getResponseCode();
            System.out.println("HTTP Status Code: " + responseCode);
            
            // Handle the response (not implemented here)

            connection.disconnect();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


Пример отправки СМС на Ruby

require 'net/http'
require 'uri'
require 'base64'

begin
    # Your API login credentials and message details
    login = 'your_login'  # replace with your login
    password = 'your_password'  # replace with your password
    phone = '+71234567890'  # replace with the recipient's phone number
    text = 'Your message text'  # replace with your message text

    # API endpoint for sending messages
    uri = URI.parse("http://api.sms-boom.ru/messages/v2/send/")
    uri.query = URI.encode_www_form({phone: phone, text: text})

    # Create the HTTP objects
    http = Net::HTTP.new(uri.host, uri.port)
    request = Net::HTTP::Get.new(uri.request_uri)

    # Set the request headers
    request.basic_auth(login, password)
    request["Content-Type"] = "application/json"

    # Make the request and print the response
    response = http.request(request)
    puts "HTTP Status Code: #{response.code}"
    puts "Response Body: #{response.body}"

rescue StandardError => e
    puts "Error: #{e.message}"
end

Зарегистрироваться
и протестировать интеграцию