PHP code example of ssheduardo / didimo-laravel
1. Go to this page and download the library: Download ssheduardo/didimo-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/ */
ssheduardo / didimo-laravel example snippets
Ssheduardo\Didimo\SmsServiceProvider::class
'Sms' => Ssheduardo\Didimo\Facades\Sms::class,
DIDIMO_USER=TU_USER
DIDIMO_PASSWORD=TU_PASSWORD
DIDIMO_ENVIRONMENT
Route::get('/sms', ['as' => 'sms', 'uses' => 'SmsController@index']);
Sms::setEnvironment('test');
//O podemos llamar al valor asignado en el config (test o live)
Sms::setEnvironment(config('didimo.environment'));
$now = date('Y-m-d H:i:s');
$newdate = date('Y-m-d\TH:i:s', strtotime('+1 hour', strtotime($now)));
Sms::createMessage('Prueba','[NUMERO_DESTINO]','Mensaje con scheduler',$newdate);
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Ssheduardo\Didimo\Facades\Sms;
class SmsController extends Controller
{
public function index()
{
//Consultar en producción
Sms::setEnvironment('live');
$id='c366018b-97ba-4a78-8183-0d975bd2620b';
$response = Sms::getMessageStatus($id);
if($response->Status == 200) {
if($response->ResponseCode == 0 && $response->ResponseMessage == 'Operation Success') {
echo "Estatus: ".$response->StatusDescription;
}
else {
echo 'Error al obtener estatus';
}
}
else{
print_r($response);
}
}
}
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Ssheduardo\Didimo\Facades\Sms;
class SmsController extends Controller
{
public function index()
{
//Consultar en producción
Sms::setEnvironment('live');
$response = Sms::getCredits();
if($response->Status == 200) {
if($response->ResponseCode == 0 && $response->ResponseMessage == 'Operation Success') {
echo "Total saldo: ".$response->Credits;
}
else {
echo 'Error al obtener saldo';
}
}
else {
print_r($response);
}
}
}
bash
php artisan vendor:publish --provider="Ssheduardo\Didimo\SmsServiceProvider"
php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Ssheduardo\Didimo\Facades\Sms;
class SmsController extends Controller
{
public function index()
{
//Enviar sms desde producción
Sms::setEnvironment('live');
$response = Sms::createMessage('Test','[NUMERO_DESTINO]','Mensaje de prueba');
if($response->Status == 200) {
if($response->ResponseCode == 0 && $response->ResponseMessage == 'Operation Success') {
echo "Enviado correctamente, id status: {$response->Id}";
}
else {
echo 'Error, no se pudo enviar el sms';
}
}
else {
print_r($response);
}
}
}