PHP code example of isurindu / rest-api-client

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

    

isurindu / rest-api-client example snippets


// Include the Composer autoloader or use your own PSR-0 autoloader
source\Sms;
use Smsglobal\RestApiClient\RestApiClient;

// Get an API key from SMSGlobal and insert the key and secret
$apiKey = new ApiKey('your-api-key', 'your-api-secret');

// All requests are done via a 'REST API client.' This abstracts away the REST
// API so you can deal with it like you would an ORM
$rest = new RestApiClient($apiKey);

// Now you can get objects
$contact = $rest->get('contact', 1); // Contact resource with ID = 1
// Edit them
$contact->setMsisdn('61447100250');
// And save them
$rest->save($contact);
// Or delete them
$rest->delete($contact);

// You can also instantiate new resources
$sms = new Sms();
$sms->setDestination('61447100250')
    ->setOrigin('Test')
    ->setMessage('Hello World');
// And save them
$rest->save($sms);
// When a new object is saved, the ID gets populated (it was null before)
echo $sms->getId(); // integer

// For an SMS, saving also sends the message, so you can use a more meaningful
// keyword for it
$sms->send($rest);

// You can get a list of available resources
$list = $rest->getList('sms');

foreach ($list->objects as $resource) {
    // ...
}

// Pagination data is