PHP code example of shoutoutlabs / shoutout-sdk

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

    

shoutoutlabs / shoutout-sdk example snippets




wagger\Client\ShoutoutClient;

$apiKey = 'XXXXXXXXX.XXXXXXXXX.XXXXXXXXX';

$client = new ShoutoutClient($apiKey,true,false);


$message = array(
    'source' => 'ShoutDEMO',
    'destinations' => ['94777123456'],
    'content' => array(
        'sms' => 'Sent via SMS Gateway'
    ),
    'transports' => ['SMS']
);

try {
    $result = $client->sendMessage($message);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when sending message: ', $e->getMessage(), PHP_EOL;
}




wagger\Client\ShoutoutClient;

$apiKey = 'XXXXXXXXX.XXXXXXXXX.XXXXXXXXX';

$client = new ShoutoutClient($apiKey,true,false);


$contact = array(
    'mobile_number' => '94777123456',//Required if not specified user_id
    'user_id' => '94777123456',//Optional. if specified, this will be used to generate the contact id, otherwise mobile_number will be used to generate contact id
    //arbitrary attributes
    'email' => '[email protected]',
    'tags' => ['lead'],
    'name' => 'Duke'
);
$contacts = array($contact);

try {
    $result = $client->createContacts($contacts);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when creating contacts ', $e->getMessage(), PHP_EOL;
}




wagger\Client\ShoutoutClient;

$apiKey = 'XXXXXXXXX.XXXXXXXXX.XXXXXXXXX';

$client = new ShoutoutClient($apiKey,true,false);


$activity = array(
    'userId' => '94777123456',//Required. your account id
    //arbitrary attributes
    'activityName' => 'Sample Activity',
    'activityData' => array(
        'param1' => 'val1',
        'param2' => 'val2',
        'param3' => 'val3'
    )
);

try {
    $result = $client->createActivity($activity);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when creating activity ', $e->getMessage(), PHP_EOL;
}