You can install the package via composer:
composer require tipytechnique/laravel-ovh-sms
First you need to set your OVH credentials on your .env
file :
OVHSMS_APP_KEY = "your-app-key"
OVHSMS_APP_SECRET = "your-app-secret"
OVHSMS_CONSUMER_KEY = "your-consumer-key"
OVHSMS_ACCOUNT = "your-sms-account"
OVHSMS_SENDER = "your-sms-sender"
To create your credentials, you can visit https://api.ovh.com/createToken/index.cgi?GET=/sms&GET=/sms/*&PUT=/sms/*&DELETE=/sms/*&POST=/sms/*
Optionally, you can publish this package's configuration file on your config
folder by running
php artisan vendor:publish --provider="TipyTechnique\LaravelOvhSms\SmsServiceProvider"
If you are using the Themosis
framework, run
php console vendor:publish --provider="TipyTechnique\LaravelOvhSms\SmsServiceProvider"
You can either use the depency injection or the Facade to manage your sms.
// Using depency injection
use Illuminate\Routing\Controller as BaseController;
use TipyTechnique\LaravelOvhSms\Contracts\Sms;
class SmsController extends BaseController
{
/**
* Get all outgoing messages
*
* @param Sms $sms
*
* @return array
*/
public function getAllSms(Sms $sms): array
{
return $sms->getMessages('incoming');
}
}
// Using Facade
use Illuminate\Routing\Controller as BaseController;
use TipyTechnique\LaravelOvhSms\Facades\Sms;
class SmsController extends BaseController
{
/**
* Get all outgoing messages
*
* @param Sms $sms
*
* @return array
*/
public function getAllSms(Sms $sms): array
{
return Sms::getMessages('incoming');
}
}
/**
* First parameter : receivers, can be a single one (string) or multiple (array)
* Second parameter : isMarketing, true or false
* Thir parameter : allowResponse, true or false
*/
$message = Sms::createMessage('+33654213566', false, false);
$message = Sms::createMessage(['+33654213566', '+33652147895'], false, true);
$message = Sms::createMessage('+33654213566', false, false);
$message->send('Hello world');
// Or with a single line
Sms::createMessage('+33654213566', false, false)->send('Hello world');
// get ongoing messages
$messages = Sms::getMessages('ongoing');
// get incoming messages
$messages = Sms::getMessages('incoming');
// get planned messages
$messages = Sms::getMessages('planned');
// for ongoing and incoming messages, you can use a second argument to set filters
// all filters are optionals
$messages = Sms::getMessages(
'ongoing',
[
'dateStart' => '2019-07-01 12:00:00', // using date as a string
'dateEnd' => new DateTime('2019-08-01'), // using DateTime object
'sender' => 'your-sender',
'receiver' => 'a-receiver',
'tag' => 'a-tag'
]
);
// get all blacklisted numbers
$blasklisted = Sms::getBlacklistedNumbers(); // array
// remove a given number from the blacklist
Sms::removeBlacklistedNumber('+33654632544');
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
Please submit your issue using the issue tracker.
The MIT License (MIT). Please see License File for more information.