PHP code example of web2sms / sms

1. Go to this page and download the library: Download web2sms/sms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

web2sms / sms example snippets


        ...
        
        use Web2sms\Sms\SendSMS;
        $sendSMS = new SendSMS();

        $sender->accountType = 'prepaid';                                 // postpaid | prepaid          // Optional
        $sendSMS->apiKey     = 'API_KEY_FROM_THE_PLATFORM';               // ApiKey from Platform        // Mandatory
        $sendSMS->secretKey  = 'SECRET_KEY_FROM_THE_PLATFORM';            // secretKey from Platform     // Mandatory

        // SMS #1
        $sendSMS->messages[]  = [
                            'sender'            => ''          ,          // who send the SMS             // Optional
                            'recipient'         => '07XXXXXXXX',          // who receive the SMS          // Mandatory
                            'body'              => 'This is the actual content of SMS nr one',            // Mandatory
                            'scheduleDatetime'  => 'YYYY-MM-DD 10:20:10', // Date & Time to send SMS      // Optional
                            'validityDatetime'  => null,                  // Date & Time of expire SMS    // Optional
                            'callbackUrl'       => 'DOMAIN/XXX/',         // Full callback URL            // Optional    
                            'userData'          => null,                  // User data                    // Optional
                            'visibleMessage'    => false                  // false / True                 // Optional
                            ];

        ...

        // SMS #N
        $sendSMS->messages[]  = [
                            'sender'            => ''          ,          // who send the SMS             // Optional
                            'recipient'         => '07XXXXXXXX',          // who receive the SMS          // Mandatory
                            'body'              => 'This is the actual content of SMS nr N'               // Mandatory
                            'scheduleDatetime'  => null,                  // Date & Time to send SMS      // Optional
                            'validityDatetime'  => null,                  // Date & Time of expire SMS    // Optional
                            'callbackUrl'       => 'DOMAIN/XXX/',         // Full callback URL            // Optional    
                            'userData'          => null,                  // User data                    // Optional
                            'visibleMessage'    => false                  // false / True                 // Optional
                            ];


        $sendSMS->setRequest();
        $sendSMS->sendSMS();

        ...