PHP code example of ilgala / laravel-smsfactor

1. Go to this page and download the library: Download ilgala/laravel-smsfactor 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/ */

    

ilgala / laravel-smsfactor example snippets


use IlGala\SMSFactor\Facades\SMSFactor;
// you can alias this in config/app.php if you like

$total_credits = SMSFactor::credits();
// Check SMS Factor documentation for more information about the results:
/*
 * $total_credits (JSON format):
 * {
 *  "credits": "2420",
 *  "message": "OK"
 * }
 *
 * $total_credits (XML format):
 * <?xml version="1.0" encoding="UTF-8"

use IlGala\SMSFactor\Facades\SMSFactor;

// the alternative connection is the other example provided in the default config
SMSFactor::connection('alternative')->credits()->credits;

// let's check how long we have until the limit will reset
SMSFactor::connection('alternative')->credits()->credits;

use IlGala\SMSFactor\Facades\SMSFactor;

// writing this:
SMSFactor::connection('main')->credits();

// is identical to writing this:
SMSFactor::credits();

// and is also identical to writing this:
SMSFactor::connection()->credits();

// this is because the main connection is configured to be the default
SMSFactor::getDefaultConnection(); // this will return main

// we can change the default connection
SMSFactor::setDefaultConnection('alternative'); // the default is now alternative

use IlGala\SMSFactor\SMSFactorManager;
use Illuminate\Support\Facades\App; // you probably have this aliased already

class SMSSender
{
    protected $smsfactor;

    public function __construct(SMSFactorManager $smsfactor)
    {
        $this->smsfactor = $smsfactor;
    }

    public function sendSms($params, $method, $simulate = false)
    {
        $this->smsfactor->send($params, $method, $simulate = false);
    }
}

App::make('SMSSender')->bar();
bash
$ php artisan vendor:publish