PHP code example of krve / inmobile

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

    

krve / inmobile example snippets


use Krve\Inmobile\Gateway;
use Krve\Inmobile\Message;

$gateway = new Gateway('api-key');

$response = $gateway->send(
    Message::create('Hello World')
        ->from('MyCompany')
        ->to(4500000000)
);

$response->toArray();

/**
 * [
 *     ['msisdn' => '4500000000', 'id' => 'id-1']
 * ] 
 */

use Krve\Inmobile\Gateway;
use Krve\Inmobile\Message;

$gateway = new Gateway('api-key');

$response = $gateway->send(
    Message::create('Hello World')
        ->from('MyCompany')
        ->to(4500000000),
    'https://example.com/callback'
);

// Response code is -11

$exception->getMessage(); // "Inmobile error: OverchargeDonationLimitExceeded"
$exception->getInmobileErrorCode(); // -11 

$exception->getMessage(); // "ERROR: unknown response from inmobile. Response code was {statusCode}"