PHP code example of dmitrakovich / smstraffic-for-laravel
1. Go to this page and download the library: Download dmitrakovich/smstraffic-for-laravel 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/ */
dmitrakovich / smstraffic-for-laravel example snippets
/**
* Get the SmsTraffic / SMS representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\SmsTrafficMessage
*/
public function toSmsTraffic($notifiable)
{
return (new SmsTrafficMessage)
->content('Your SMS message content');
}
/**
* Get the SmsTraffic / SMS representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\SmsTrafficMessage
*/
public function toSmsTraffic($notifiable)
{
return (new SmsTrafficMessage)
->content('Your unicode message')
->route('whatsapp(180)-sms');
}
/**
* Get the SmsTraffic / SMS representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\SmsTrafficMessage
*/
public function toSmsTraffic($notifiable)
{
return (new SmsTrafficMessage)
->content('Your SMS message content')
->from('15554443333');
}
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable;
/**
* Route notifications for the SmsTraffic channel.
*
* @param \Illuminate\Notifications\Notification $notification
* @return string
*/
public function routeNotificationForSmsTraffic($notification)
{
return $this->phone_number;
}
}
SmsTraffic::send($phones, $message);
use Illuminate\Notifications\Client\Response\SmsTrafficStatusCollectionResponse;
use Illuminate\Notifications\Facades\SmsTraffic;
$response = SmsTraffic::status('165314138129206752561536268436567490747');
if ($response instanceof SmsTrafficStatusCollectionResponse) {
foreach ($response->getStatuses() as $status) {
$status->getSmsId();
$status->getStatus(); // Delivered, READ, DELIVERED, ...
$status->getChannel(); // viber, sms, ... (Smart Delivery only)
$status->getDeliveryDate();
$status->getReadDate();
$status->getSubmissionDate();
$status->getSendDate();
$status->getLastStatusChangeDate();
$status->getError(); // per-message error, if any
$status->isFinal(); // true for terminal statuses
}
}
// Multiple ids (max 15)
$response = SmsTraffic::status([
'8287713301',
'8287713302',
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.