PHP code example of ziswapp / zenziva-client-api

1. Go to this page and download the library: Download ziswapp/zenziva-client-api 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/ */

    

ziswapp / zenziva-client-api example snippets





use Ziswapp\Zenziva\ClientFactory;
use Symfony\Component\HttpClient\HttpClient;

$url = '';
$key = '';
$secret = '';

$httpClient = HttpClient::create();

// Crete client
$regular = ClientFactory::regular($httpClient, $key, $secret); // Regular client
$masking = ClientFactory::masking($httpClient, $key, $secret); // Masking client
$otp = ClientFactory::otp($httpClient, $key, $secret); // Masking with otp client
$smsCenter = ClientFactory::center($httpClient, $key, $secret, $url); // SMS Center client

// Alternative
$regular = ClientFactory::make($httpClient, ClientFactory::TYPE_REGULAR, $key, $secret); // Regular client
$masking = ClientFactory::make($httpClient, ClientFactory::TYPE_MASKING, $key, $secret); // Masking client
$otp = ClientFactory::make($httpClient, ClientFactory::TYPE_MASKING_OTP, $key, $secret); // Masking with otp client
$smsCenter = ClientFactory::make($httpClient, ClientFactory::TYPE_SMS_CENTER, $key, $secret, $url); // SMS Center client

// Zenziva Regular Operation
$httpClient = HttpClient::create();
$regular = ClientFactory::make($httpClient, ClientFactory::TYPE_REGULAR, $key, $secret); // Regular client
$regular->send('081318788271', 'Sending notification.'); // Return array

// Zenziva Masking Operation
$httpClient = HttpClient::create();
$masking = ClientFactory::make($httpClient, ClientFactory::TYPE_MASKING, $key, $secret); // Masking client
$masking->balance(); // Check balance return Credit object
$masking->send('081318788271', 'Sending notification.'); // Return Outbox object
$masking->setIsOtp(true); // Change to masking otp client

// Zenziva SMS Center Operation
$smsCenter = ClientFactory::make($httpClient, ClientFactory::TYPE_SMS_CENTER, $key, $secret, $url); // SMS Center client
$smsCenter->balance(); // Check balance return Credit object, will be throw CreditExpiredException or CreditLimitException if balance is 0 and expired date < now
$smsCenter->send('081318788271', 'Sending notification.'); // Return Outbox object
$smsCenter->outbox(new DateTime(), new DateTime()); // Get outbox by date, return array Outbox object
$smsCenter->inbox(new DateTime(), new DateTime()); // Get inbox by date, return array Inbox object
$smsCenter->status('messageId'); // Get status sms by messageId, return Outbox object