1. Go to this page and download the library: Download parables/arkesel-sdk 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/ */
parables / arkesel-sdk example snippets
$builder = (new ArkeselMessageBuilder)
->message('Hello World')
->recipients(["233234567890", "233234567890"])
->recipients("233234567890,233234567890") // alternative
->sandbox(false);
// helper function
$response = arkeselSms(builder: $builder)->send();
// facade
$response = ArkeselSms::make(builder: $builder)->send();
// instance
$response = new ArkeselSms(builder: $builder)->send();
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable;
}
namespace App\Notifications;
use Parables\ArkeselSdk\BulkSms\ArkeselMessageBuilder;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Bus\Queueable;
class WelcomeMessage extends Notification implements ShouldQueue
{
use Queueable;
protected string $message;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(string $message)
{
$this->message = $message;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['arkesel'];
}
/**
* the content of the notification to be sent.
*
* @param mixed $notifiable
* @return string|ArkeselMessageBuilder
*/
public function toArkesel($notifiable)
{
return $this->message;
}
}
use App\Notifications\WelcomeMessage;
$user->notify(new WelcomeMessage($message));
use Illuminate\Support\Facades\Notification;
Notification::send($users, new WelcomeMessage($message));
Notification::route('arkesel', ['233123456789', '233123456789'])->notify(new WelcomeMessage($message));
// alternative
Notification::route('arkesel', '233123456789,233123456789')->notify(new WelcomeMessage($message));
public function toArkesel($notifiable)
{
return (new ArkeselMessageBuilder())
->message('Hello World')
->recipients(["233123456789", "233123456789"]);
->recipients("233123456789,233123456789") // alternative
}
public function toArkesel($notifiable)
{
return 'Hello World';
}
public function routeNotificationForArkesel($notification)
{
return ['233123456789','233123456789'];
// or
return '233123456789,233123456789';
}
/**
* Get the recipients from methods and properties defined on the `$notifiable` class
*
* @param mixed $notifiable
* @param Notification $notification
* @return string|array
*/
private function getRecipientsFromNotifiable($notifiable, Notification $notification): string|array
{
return $this->getValueFromMethodOrProperty('routeNotificationForArkesel', $notifiable, $notification)
?? $this->getValueFromMethodOrProperty('recipients', $notifiable, $notification)
?? $this->getValueFromMethodOrProperty('recipient', $notifiable, $notification)
?? $this->getValueFromMethodOrProperty('phoneNumbers', $notifiable, $notification)
?? $this->getValueFromMethodOrProperty('phone_numbers', $notifiable, $notification)
?? $this->getValueFromMethodOrProperty('phoneNumber', $notifiable, $notification)
?? $this->getValueFromMethodOrProperty('phone_number', $notifiable, $notification)
?? []; // [] is a fallback that will throw an exception
}
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class GetRecipientsOrderOfPreference
{
use Notifiable;
/*1st*/
public function routeNotificationForArkesel($notification)
{
return ['233123456789','233123456789']
}
/*2nd*/
public function recipients($notification)
{
return ['233123456789','233123456789']
}
/*3rd*/
public string $recipients = ['233123456789','233123456789'];
/*4th*/
public function recipient($notification)
{
return ['233123456789','233123456789']
}
/*5th*/
public string $recipient = ['233123456789','233123456789'];
/*6th*/
public function phoneNumbers($notification)
{
return ['233123456789','233123456789']
}
/*7th*/
public string $phoneNumbers = ['233123456789','233123456789'];
/*8th*/
public string $phone_numbers = ['233123456789','233123456789'];
/*9th*/
public function phoneNumber($notification)
{
return ['233123456789','233123456789']
}
/*10th*/
public string $phoneNumber = ['233123456789','233123456789'];
/*11th*/
public string $phone_number = ['233123456789','233123456789'];
}
public function toArkesel($notifiable)
{
return (new ArkeselMessageBuilder())
->message("Your message")
->recipients(["233123456789", "233123456789"])
->recipients("233123456789,233123456789") // alternative
->apiKey("your API key") # this overrides the `.env` variable
->schedule(now()->addMinutes(5))
->sender("Company") // less than 11 characters
->callbackUrl("https://my-sms-callback-url")
->sandbox(false)
}
$builder = new ArkeselMessageBuilder();
$builder->schedule($now->addMinutes(5));
$builder->schedule('first day of May 2022');
// Create an instance
(new ArkeselSms(builder: $builder))->send();
// OR: Use the Facade
ArkeselSms::make(builder: $builder)->send();
// OR: Use the helper function
arkeselSms(builder: $builder)->send();