1. Go to this page and download the library: Download squareetlabs/laravel-smsup 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/ */
public function via(INotifiable $notifiable)
{
return ['smsUp'];
}
use SquareetLabs\LaravelSmsUp\SmsUpMessage;
...
public function toSmsUp(INotifiable $notifiable)
{
$message = new SmsUpMessage();
$message->to('34xxxxxxxxx')
->from('Foo')
->text('Text of your message')
->custom('MyMsgID-12345') // Optional.
->link('http://www.google.com'); // Optional
return $message;
}
/**
* Route notifications for the SmsUp channel.
*
* @return string
*/
public function routeNotificationForSmsUp(): string
{
return $this->phone;
}
->text('Hi John! See our new offers only available for you: {LINK}');
use SquareetLabs\LaravelSmsUp\SmsUpMessage;
use SquareetLabs\LaravelSmsUp\Facades\SmsUp;
...
$message1 = new SmsUpMessage();
$message->to('34xxxxxxxxx')
->from('Foo')
->text('Text of your message')
->custom('MyMsgID-12345') // Optional.
->link('http://www.google.com'); // Optional
$message2 = new SmsUpMessage();
$message2->to('34xxxxxxxxx')
->from('Foo')
->text('Text of your message')
->custom('MyMsgID-12346') // Optional.
->link('http://www.google.com'); // Optional
$messages = [
$message1->formatData(),
$message2->formatData()
];
SmsUp::sendMessages($messages);
use SquareetLabs\LaravelSmsUp\Facades\SmsUp;
...
$balance = SmsUp::getBalance();
use SquareetLabs\LaravelSmsUp\Facades\SmsUp;
...
$verify = SmsUp::verifyPhone('34xxxxxxxxx');
use SquareetLabs\LaravelSmsUp\Events\SmsUpMessageWasSent;
use SquareetLabs\LaravelSmsUp\SmsUpMessage;
use SquareetLabs\LaravelSmsUp\SmsUpResponse;
use SquareetLabs\LaravelSmsUp\SmsUpResponseMessage;
class SmsUpMessageSentListener
{
/**
* Handle the event.
*
* @param SmsUpMessageWasSent $event
* @return void
*/
public function handle(SmsUpMessageWasSent $event)
{
$response = $event->response; // Class SmsUpResponse
$message = $event->message; // Class SmsUpMessage
if ($response->getStatus() != 'ok') {
$yourModel = YourModel::find($message->getCustom());
$yourModel->sms_status = $response->getStatus();
$yourModel->sms_error_id = $response->getErrorId();
$yourModel->sms_error_msg = $response->getErrorMsg();
$yourModel->save();
} else {
foreach ($response->getResult() as $responseMessage) { // class SmsUpResponseMessage
$yourModel = YourModel::find($responseMessage->getCustom());
$yourModel->sms_status = $responseMessage->getStatus();
$yourModel->sms_id = $responseMessage->getSmsId();
$yourModel->sms_error_id = $responseMessage->getErrorId();
$yourModel->sms_error_msg = $responseMessage->getErrorMsg();
$yourModel->save();
}
}
}
}