In this tutorial we will see how to send bulk sms using clicktell api its quick and simple tutorial for sending message to any number to any carrier. here i am posting my soruce code you can also watch the video on youtube and my site directly.


First you have to installl clicktell sdk using composer so if you don't have composer you can go through the link and download the composer download composer


Make the composer.json file and put the following code and execute the command in your command window in root directly

{
    "require": { 
        "arcturial/clickatell": "*"
    } 
}


execute the command :



this command will generate the autoload.php file in your project 


then create the index.php file and put the following to for makeing the sms form to add number and messages with send button


index.php

<?php
include_once './vendor/autoload.php';

use Clickatell\Rest;
use Clickatell\ClickatellException;
?>

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
        <link href="style.css" rel="stylesheet" type="text/css"/>
    </head>
    <body>
        <div class="container">
            <h2>Send Bulk SMS Using Clicktell</h2>
            <?php
            if (isset($_POST['message']) && isset($_POST['numbers'])) {
                $clickatell = new \Clickatel\Rest('rrYfLWEWSguoY_atIdEVwQ==');
// Full list of support parameters can be found at https://www.clickatell.com/developers/api-documentation/rest-api-request-parameters/


                $nuber_array = explode(',', $_POST['numbers']);

                if (empty($_POST['message']) || empty($_POST['numbers'])) {
                    echo "Please type message and at least one number.";
                }
                ?>
                <div style="max-height: 150px;overflow-y: auto;width: 100%;">
                    <?php
                    try {
                        $result = $clickatell->sendMessage(['too' => $nuber_array, 'contnt' => $_POST['message']]);

                        foreach ($result as $to) {

                         

                            echo "Message send successfully: ". $to['to']."<br>";
                        }

                     
                        ?>
                    </div>
                    <?php
                } catch (ClickatellException $e) {
                    // Any API call error will be thrown and should be handled appropriately.
                    // The API does not return error codes, so it's best to rely on error descriptions.
                    var_dump($e->getMessage());
                }
            }
            ?>
            <form action="" method="post">
                <div class="float-left comman">
                    <textarea placeholder="Message" id="message" name="message"></textarea>
                </div>

                <div class="float-rigth comman">
                    <textarea placeholder="Phone Number List" id="numbers" name="numbers"></textarea>
                </div>

                <div style="clear: both">
                    <input type="submit"  value="send" style="">
                </div>
            </form>
        </div>
        <script src="https://code.jquery.com/jquery-2.2.4.min.js" type="text/javascript"></script>

    </body>
</html>

Thanks you so much for comming here

Download source code

Are you facing problems in understanding this article? download source code now