PHP code example of ashik / adn-sms

1. Go to this page and download the library: Download ashik/adn-sms 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/ */

    

ashik / adn-sms example snippets

bash
php artisan vendor:publish --tag=adn-sms-config
 php
use Ashik\AdnSms\Facades\AdnSms;

class SmsController
{
    /**
     * Make request and return response
     *
     * @return \Illuminate\Http\Client\Response
     * @throws \Throwable
     */
    public function send()
    {
        $response = AdnSms::to('01XXXXXXXXX')
            ->message('Send SMS Test.')
            ->send();
        
        return $response->json();
    }
}
 php
use Ashik\AdnSms\Facades\AdnSms;

class SmsController
{
    /**
     * Make request and return response
     *
     * @return \Illuminate\Http\Client\Response
     * @throws \Throwable
     */
    public function otp()
    {
        $response = AdnSms::otp('01XXXXXXXXX')
            ->message('Send OTP SMS Test.')
            ->send();

        return $response->json();
    }
}
 php
use Ashik\AdnSms\Facades\AdnSms;

class SmsController
{
    /**
     * Make request and return response
     *
     * @return \Illuminate\Http\Client\Response
     * @throws \Throwable
     */
    public function bulk()
    {
        $response = AdnSms::bulk(['019XXXXXXXX', '015XXXXXXXX'])
            ->campaignTitle('Bulk SMS Test')
            ->message('Send Bulk SMS Test.')
            ->send();
        
        return $response->json();
    }
}
 php
use Ashik\AdnSms\Facades\AdnSms;
use Illuminate\Http\Client\Response;
use App\Models\Table;

class SmsController
{
    public function bulk()
    {
        AdnSms::bulk(['019XXXXXXXXX', '02XXXXXXXXX'])
            ->campaignTitle('Bulk SMS Test')
            ->message('Send Bulk SMS Test.')
            ->queue(function (Response $response) {
                // Check if the response body is empty
                if ($response->body() != "") {
                    // Store the $response in the database
                    $model = new Table();
                    $model->data = $response->body();
                    $model->save();
                }
            });
    }
}
 php
use Ashik\AdnSms\Facades\AdnSms;

class SmsController
{
    /**
     * Make request and return response
     *
     * @return \Illuminate\Http\Client\Response
     * @throws \Throwable
     */
    public function someFunction()
    {
        $response = AdnSms::checkBalance();
        
        return $response->json();
    }
}
 php
use Ashik\AdnSms\Facades\AdnSms;

class SmsController
{
    /**
     * Make request and return response
     *
     * @return \Illuminate\Http\Client\Response
     * @throws \Throwable
     */
    public function smsStatus()
    {
        $response = AdnSms::checkSmsStatus('SXXXXXXXXXXXXXXXX');
        
        return $response->json();
    }
}
 php
use Ashik\AdnSms\Facades\AdnSms;

class SmsController
{
    /**
     * Make request and return response
     *
     * @return \Illuminate\Http\Client\Response
     * @throws \Throwable
     */
    public function campaignStatus()
    {
        $response = AdnSms::checkCampaignStatus('CXXXXXXXXXXXXXXXX');
        
        return $response->json();
    }
}