PHP SEND

By
 PHP Code Example - Sending SMS
 
<?php
function sendSMS($senderId, $recipient, $messageText) {
    $apiUrl = 'https://rest.sendmode.com/v2/send';
    $apiKey = 'YOUR_ACCESS_KEY';

    $message = [
        'messagetext' => $messageText,
        'senderid' => $senderId,
        'recipients' => [$recipient]
    ];

    $data = http_build_query(['message' => json_encode($message)]);

    $options = [
        'http' => [
            'header'  => "Content-type: application/x-www-form-urlencoded\r\n" .
                         "Authorization: $apiKey\r\n",
            'method'  => 'POST',
            'content' => $data
        ]
    ];

    $context  = stream_context_create($options);
    $result = file_get_contents($apiUrl, false, $context);

    if ($result === FALSE) {
        throw new Exception('Error sending SMS');
    }

    echo $result;
}

// Example usage
sendSMS('your_senderid', 'recipient_number', 'your_message_content');
?>

Read more

C# SEND

By
C# Code Example - Sending SMS

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

public class SendmodeClient
{
    private static readonly HttpClient client = new HttpClient();
    private const string ApiUrl = "https://rest.sendmode.com/v2/send";
    private const string ApiKey = "YOUR_ACCESS_KEY";

    public static async Task SendSMS(string senderId, string recipient, string messageText)
    {
        var message = new
        {
            messagetext = messageText,
            senderid = senderId,
            recipients = new[] { recipient }
        };

        var jsonMessage = JsonConvert.SerializeObject(message);
        var content = new StringContent($"message={jsonMessage}", Encoding.UTF8, "application/x-www-form-urlencoded");

        client.DefaultRequestHeaders.Clear();
        client.DefaultRequestHeaders.Add("Authorization", ApiKey);

        HttpResponseMessage response = await client.PostAsync(ApiUrl, content);
        string responseBody = await response.Content.ReadAsStringAsync();

        Console.WriteLine(responseBody);
    }

    public static async Task Main(string[] args)
    {
        await SendSMS("your_senderid", "recipient_number", "your_message_content");
    }
}

Read more