PHP code example of zenapply / laravel-sms

1. Go to this page and download the library: Download zenapply/laravel-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/ */

    

zenapply / laravel-sms example snippets


LeadThread\Sms\Providers\SmsServiceProvider::class

"Sms" => "LeadThread\Sms\Facades\Sms",

# Send one text
$message  = "Hello Phone!";
$to       = "+15556667777";
$from     = "+17776665555";
$response = Sms::send($message,$to,$from);

# Send many texts
$message  = "Hello Phone!";
$to       = ["+15556667777","+15556667778","+15556667779"];
$from     = "+17776665555";
$response = Sms::sendMany($message,$to,$from);

# Send many texts with different messages
$items = [
  ["msg"=>"Hello Rick!", "to"=>"+15556667777","from"=>"+17776665555"],
  ["msg"=>"Hello Tyler!","to"=>"+15556667778","from"=>"+17776665555"],
  ["msg"=>"Hello Karla!","to"=>"+15556667779","from"=>"+17776665555"],
];
$response = Sms::sendArray($items);

//If you updated your aliases array in "config/app.php"
use Sms;
//or if you didnt...
use LeadThread\Sms\Facades\Sms;

$areacode = '435';
//Search for a number to buy
//The response is different for each SMS service provider. This example shows Plivo.
$response = Sms::searchNumber($areacode);
$number = $response['response']['objects'][0]['number'];

//Buy the number
Sms::buyNumber($number);

//Unrent the number
Sms::sellNumber($number);
bash
php artisan vendor:publish