PHP code example of apilitylabs / keysms

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

    

apilitylabs / keysms example snippets




use KeySMS\SMS;

SMS::to('+4781549300')
    ->from('Acme Inc')
    ->message('Hello, World!');

SMS::to(['+4781549300', '+4799999999']);

$user = Auth::user();

SMS::to($user)->message('Hello!');



namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

use KeySMS\SMS;

class HelloWorld extends Notification implements ShouldQueue
{
    /**
     * Get the notification's delivery channels.
     *
     * @return array<int, string>
     */
    public function via(object $notifiable): array
    {
        return ['keysms'];
    }

    public function toSMS($notifiable)
    {
        return 'Hello, World!';
    }
}



use App\Notifications\HelloWorld;

$user = Auth::user();

$user->notify(new HelloWorld);



use KeySMS\Facades\KeySMS;
use KeySMS\SMS;

// Called once to initialise the KeySMS client
KeySMS::init(<your username>, <your api key>);

SMS::to('+4781549300')
    ->message('Hello, World!')
    ->send();
ini
KEYSMS_USERNAME=<your username>
KEYSMS_API_KEY=<your api key>
ini
KEYSMS_DEFAULT_SENDER="Acme Inc"