PHP code example of kemonai / zigatext-php

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

    

kemonai / zigatext-php example snippets


    $zigatext = new Kemonai\Zigatext(ACCESS-KEY);
    try
    {
        $response = $zigatext->message->send(['sender' => 'php lib',
                                        'message' => 'it is awesome',
                                        'recipients' => '23470xxxxxxxx',
                                        'use_corporate_route' => true, // [true or false]
                                        'callback_url' => 'http://your-website/your-callback-url',  
                                        ]);
        var_dump($response);

    } catch(\Kemonai\Zigatext\Exception\ApiException $e){
        print_r($e->getResponseObject());
        die($e->getMessage());
    }

    $zigatext = new Kemonai\Zigatext(ACCESS-KEY);
    try
    {
        $response = $zigatext->message->schedule(['sender' => 'php lib',
                                    'message' => 'it is awesome',
                                    'recipients' => '23470xxxxxxxx',
                                    'use_corporate_route' => true,
                                    'callback_url' => 'http://your-website/your-callback-url',
                                    'extras' => [[
                                        'deliver_at' => '2019-07-23 10:10',
                                        'time_zone_id' => 2,
                                    ]]]);
        var_dump($response);

    } catch(\Kemonai\Zigatext\Exception\ApiException $e){
        print_r($e->getResponseObject());
        die($e->getMessage());
    }

    $zigatext = new Kemonai\Zigatext(ACCESS-KEY);
    try
    {
        $response =  $zigatext->newsletter->addSubscriber([
                                    'id' => 2, //sms newsletter id
                                    'name' => 'Chibuike Mba',
                                    'phone_no' => '23470xxxxxxxx']);
        var_dump($response);

    } catch(\Kemonai\Zigatext\Exception\ApiException $e){
        print_r($e->getResponseObject());
        die($e->getMessage());
    }

    $zigatext = new Kemonai\Zigatext(ACCESS-KEY);
    try
    {
        $response =  $zigatext->newsletter->addBulkSubscribers([
                                        'id' => 2, //sms newsletter id
                                        'subscribers' => [
                                            [
                                                'name' => 'Benjamin Akawu',
                                                'phone_no' => '23470xxxxxxxx'
                                            ],
                                            [
                                                'name' => 'Franklin Nnakwe',
                                                'phone_no' => '23480xxxxxxxx'
                                            ]
                                        ]
                                    ]);
        var_dump($response);

    } catch(\Kemonai\Zigatext\Exception\ApiException $e){
        print_r($e->getResponseObject());
        die($e->getMessage());
    }

    $zigatext = new Kemonai\Zigatext(ACCESS-KEY);
    try
    {
        $response =  $zigatext->birthday->addContactToGroup([
                                        'group_id' => 7,
                                        'name' => 'Dennis Okonnachi',
                                        'phone_no' => '23470xxxxxxxx',
                                        'day' => 9,
                                        'month_id' => 1,
                                    ]);
        var_dump($response);

    } catch(\Kemonai\Zigatext\Exception\ApiException $e){
        print_r($e->getResponseObject());
        die($e->getMessage());
    }

    $zigatext = new Kemonai\Zigatext(ACCESS-KEY);
    try
    {
        $response =  $zigatext->birthday->addBulkContactsToGroup([
                                        'group_id' => 7,
                                        'contacts' => [
                                            [
                                            'name' => 'Caleb Uche',
                                            'phone_no' => '23470xxxxxxxx',
                                            'day' => 9,
                                            'month_id' => 1,
                                            ],
                                            [
                                            'name' => 'Bernard Inyang',
                                            'phone_no' => '23480xxxxxxxx',
                                            'day' => 19,
                                            'month_id' => 3,
                                            ]
                                        ]
                                    ]);
        var_dump($response);

    } catch(\Kemonai\Zigatext\Exception\ApiException $e){
        print_r($e->getResponseObject());
        die($e->getMessage());
    }

    $builder = new MetadataBuilder();

    MetadataBuilder::$auto_snake_case = false;
 bash
    $ composer 
 php