PHP code example of alresia / laravel-wassenger

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

    

alresia / laravel-wassenger example snippets




namespace App\Http\Controllers;

use Alresia\LaravelWassenger\Messages;

class SampleController extends Controller
{
    public function sendMessage()
    {
        $phone = '+1234567890';
        $message = 'Hello world! This is a simple test message';
        Messages::message($phone, $message)->send();

    }

}


Alresia\LaravelWassenger\Wassenger;

    $phone = '+1234567890';
    $message = 'Hello world! This is a simple test message';
    Messages::message($phone, $message)->send();




use Alresia\LaravelWassenger\Messages;

ello world! This is a simple test message';
    Messages::message($phone, $message)->send();


return [
    'authorisation' => [
        'api_key' => env('WASSENGER_API_KEY', ''),
        'api_host'   => env('WASSENGER_API_URL', 'https://api.wassenger.com'),
        'api_version' => 1,
        'default_device' => env('DEFAULT_DEVICE', '')
    ],
    'http_client' => [
        'return_json_errors' => false,
    ],
];



namespace Alresia\LaravelWassenger;

class Config
{
    public const API_KEY = '';
    public const API_HOST = 'https://api.wassenger.com';
    public const API_VERSION = 1;
    public const DEFAULT_DEVICE = null;

    public const RETURN_JSON_ERRORS = false;


WASSENGER_API_KEY=<YOUR_KEY_HERE>
DEFAULT_DEVICE=<DEVICE_ID_HERE>

'http_client' => [
        'return_json_errors' => true,
    ],

 public const RETURN_JSON_ERRORS = true;

use Alresia\LaravelWassenger\Wassenger;

Wassenger::numberExist('+1234567890');

Wassenger::sessionSync('63615bb1db0ssb686cee2fa4a');

Wassenger::sync('63615bb1db0ssb686cee2fa4a');

Wassenger::syncAll();

use Alresia\LaravelWassenger\Messages;

Messages::message('+1234567890', 'Hello world! This is a simple test message')
    ->send();

Messages::messageGroup('[email protected]', 'Hello world! This is a simple test message', 'high')
    ->send();

Messages::messageGroup('+1234567890', 'Hello world! This is a test media message.', 'high')
    ->media(['file', '<24 characters length file ID>'])
    ->send();

Messages::message('+1234567890', 'Hello world! This is a simple test message', false)
    ->send();

Messages::message('+1234567890', 'Hello world! This is a simple test message')
    ->schedule('1h')
    ->send();

Messages::message('+1234567890', 'Hello world! This is a simple test message')
    ->deliverAt('2000-01-01T01:00:00+1200')
    ->send();

$buttons = [
    [
         "id" => "id1",
         "kind" => "call",
         "text" => "Call us",
         "value" => "+2348055995704"
    ],
    [
        "id" => "id2",
        "kind" => "url",
        "text" => "Open me",
        "value" => "https://company.com/shop"\
    ],
    [
        "id" => "id3",
        "text" => "Get help"
    ]
];
Messages::message('+1234567890', 'Hello world! This is a simple test message')
    ->buttons($buttons)
    ->send();

Messages::findById('635889e9133a76fddfdfy65r5')
    ->get();

Messages::findById('635889e9133a76fddfdfy65r5')
    ->message('+1234567890', 'Hello world! This is a simple test message')
    ->update();

Messages::findById('635889e9133a76fddfdfy65r5')
    ->delete();

Messages::delete('635889e9133a76fddfdfy65r5');

use Alresia\LaravelWassenger\Device;

Devices::get();

Devices::findById('63615bb1db0b686cee2fa4af')->get();

Devices::search('+2348113536471,61b37a069cba0c15d6c81000')->get();

Devices::status('verified')->get();

Devices::status('pending')->get();

Devices::session('online')->get();

Devices::session('any')->get();

Devices::search('+2348113536471,61b37a069cba0c15d6c81000')->status('verified')->get();

Devices::search('+2348113536471,61b37a069cba0c15d6c81000')->session('online')->get();

Devices::search('+2348113536471,61b37a069cba0c15d6c81000')->session('online')->get();

Devices::limit(20, 2)->get(); // size 20 page 2

Devices::search('+2348113536471,61b37a069cba0c15d6c81000')->session('online')->limit(20, 3)->get(); // size 20 page 3

Devices::session('any')->status('any')->limit(20, 0)->get(); // get() should always be the last

Devices::get([
    'search' => '+2348113536471,61b37a069cba0c15d6c81000',
    'status' => 'any',
    'sessionStatus' => 'online',
    'size' => '20',
    'page' => '3',
]); 

use Alresia\LaravelWassenger\Session;

Session::sync('63615bb1db0b686cee2fa4af');
shell
php artisan vendor:publish --provider="Alresia\LaravelWassenger\WassengerServiceProvider" --tag="config"