PHP code example of daniyal2959 / persian-sms

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

    

daniyal2959 / persian-sms example snippets




$apiKey = '<YOUR_API_KEY>';
$sms = new SMS($apiKey);
$response = $sms->driver('kavenegar')
    ->text('<MESSAGE_TO_SEND>')
    ->from('<SERVICE_PROVIDER_NUMBER>')
    ->to('<ARRAY_OF_PHONE_NUMBERS>')
    ->send();

$apiKey = '<YOUR_API_KEY>';
$sms = new SMS($apiKey);
$response = $sms->driver('kavenegar')
    ->pattern('<YOUR_PATTERN_NAME>')
    ->data('<ARRAY_OF_PATTERN_VALUES>') #E.g:['%token' => '1234']
    ->from('<SERVICE_PROVIDER_NUMBER>')
    ->to('<ARRAY_OF_PHONE_NUMBERS>')
    ->send();

$apiKey = '<YOUR_API_KEY>';
$sms = new SMS($apiKey);
$response = $sms->driver('ippanel')
    ->text('<MESSAGE_TO_SEND>')
    ->from('<SERVICE_PROVIDER_NUMBER>')
    ->to('<ARRAY_OF_PHONE_NUMBERS>')
    ->send();

$apiKey = '<YOUR_API_KEY>';
$sms = new SMS($apiKey);
$response = $sms->driver('ippanel')
    ->pattern('<YOUR_PATTERN_CODE>')
    ->data('<ARRAY_OF_PATTERN_VALUES>')
    ->from('<SERVICE_PROVIDER_NUMBER>')
    ->to('<ARRAY_OF_PHONE_NUMBERS>')
    ->send();

namespace Sms\Driver;

use Sms\Contract\IDriver;
use Sms\Driver;

class MyDrive extends Driver implements IDriver
{
    const BASE_URL = '';
    
    /**
     * @return void
     */
    public function __construct()
    {
        $this->client = new Http(self::BASE_URL, 30, []);
    }
    
    /**
     * @return bool|mixed|string
     */
    public function sendPattern()
    {
        // TODO: Implement send pattern code for current service provider
    }

    /**
     * @param $text
     * @return bool|mixed|string
     */
    public function message($text)
    {
        // TODO: Implement send message code for current service provider
    }
    
    /**
     * @return void
     */
    public function setCredential()
    {
        // TODO: Implement set credential code for current service provider
    }
}