shikiryu / laravel-ovh-sms
OVH wrapper for Laravel
Requires
- php: >=5.5.0
- illuminate/support: 4.*|5.*|6.*
- ovh/ovh: ^2.0
This package is auto-updated.
Last update: 2024-12-13 22:50:58 UTC
README
Introduction
This package is an unofficial wrapper for OVH SMS Service intended for Laravel 5+.
This project used php-ovh api (https://github.com/ovh/php-ovh) - v2.0.1.
Installation
- Require package with composer
composer require okn/laravel-ovh-sms
- Only for Laravel version < 5.5
Add the service provider and class alias for facade support inconfig/app.php
'providers' => [ // ... Okn\OvhSms\OvhSmsServiceProvider::class ]; 'aliases' => [ // ... 'OvhSms' => Okn\OvhSms\Facades\OvhSms::class ];
- Run artisan command to install the service
php artisan ovhsms:install
This command will create a default config file config/ovhsms.php
.
Configuration
Application keys must be defined in the .env
file as follow:
OVHSMS_APP_KEY= OVHSMS_APP_SECRET= OVHSMS_CONSUMER_KEY= OVHSMS_ENDPOINT= OVHSMS_SERVICE_NAME=
To make this library works with your project you need to define
homogeneous routes rights (all ending with a trailing slash or none).
Default config add one (ex: /sms/*/jobs
becomes /sms/*/jobs/
), so to fit your rights you might add the following line in your .env
file:
OVHSMS_TRAILING_SLASH=false
Usage
Default use
- Create a message
$sms = OneSignal::createMessage('This my sms. Can you read it ?');
- Send message
$smsStatus = $sms->send(['+xxxxxxxxxxx']);
Limit parts of sms to be sent
$sms->limitParts(1)->send(['+xxxxxxxxxxx']);
This will throw an exception if sms parts estimated number is greater than the limit you defined.
Exception(s)
cURL error 60: SSL certificate problem...
cURL need an SSL certificate to communicate through https protocol.
Solution 1 (recommended)
Install an SSL certificate on your local machine
Assuming you are using WAMP on Windows:
- download an SSL certificate for your local server https://curl.haxx.se/ca/cacert.pem
- put it in your prefered directory (mine is
C:\Users\[MY-USERNAME]\cacert.pem
) - edit this variable in your
php.ini
to add the path to the certificate
curl.cainfo = "C:\Users\[MY-USERNAME]\cacert.pem"
- restart your webserver
Now it should works, if it doesn't you might try the next solution.
Solution 2
Disable SSL validation (not recommended)
In .env
file you can add the following line:
OVHSMS_VERIFY_SSL=false