PHP code example of talkylabs / reach-sdk

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

    

talkylabs / reach-sdk example snippets


// Send an SMS using Reach's REST API and PHP

// Required if your environment does not handle autoloading
 new Reach\Rest\Client($apiUser, $apiKey);

// Use the Client to make requests to the Reach REST API
$client->messaging->messagingItems->send(
    '+15558675309', '+15017250604', "Hey Jenny! Good luck on the bar exam!"
);


// Require the bundled autoload file - the path may need to change
// based on where you downloaded and unzipped the SDK
\Client($apiUser, $apiKey);

// Use the Client to make requests to the Reach REST API
$client->messaging->messagingItems->send(
    // The number you'd like to send the message to
    '+15558675309', '+15017250604', "Hey Jenny! Good luck on the bar exam!"
);


User = "XXXXXXXX";
$apiKey = "YYYYYY";
$client = new Reach\Rest\Client($apiUser, $apiKey);

// Get an object using its SID. If you do not have a SID,
// check out the list resource examples on this page
$msg = $client->messaging->messagingItems()->fetch("XXed11f93dc08b952027ffbc406d0868");
print $msg->dest;


User = "XXXXXXXX";
$apiKey = "YYYYYY";
$client = new Reach\Rest\Client($apiUser, $apiKey);

// Loop over the list of messagingItems and print a property from each one
foreach ($client->messaging->messagingItems->read() as $msg) {
    print $msg->dest;
}

$apiUser = "XXXXXXXX";
$apiKey = "YYYYYY";

$client = new Reach\Rest\Client($apiUser, $apiKey);
$client->setLogLevel('debug');


Reach\Exceptions\ConfigurationException;
use Reach\Rest\Client;

$apiUser = "XXXXXXXX";
$apiKey = "YYYYYY";

// Attempt to create a new Client, but your credentials may contain a typo
try {
    $client = new Reach\Rest\Client($apiUser, $apiKey);
} catch (ConfigurationException $e) {
    // You can `catch` the exception, and perform any recovery method of your choice
    print $e . getCode();
}

$msg = $client->messaging->messagingItems()->
    ->fetch("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

print $msg->dest;


Reach\Exceptions\ReachException;
use Reach\Http\CurlClient;

$apiUser = "XXXXXXXX";
$apiKey = "YYYYYY";
$client = new Reach\Rest\Client($apiUser, $apiKey);

try {
    $client = new CurlClient();

    $client->options(
        'GET',
        'http://api.reach.talkylabs.com',
        array(),
        array(),
        array(),
        $apiUser,
        $apiKey
    );
} catch (EnvironmentException $e) {
    print $e . getCode();
}


Reach\Exceptions\ReachException;

$apiUser = "XXXXXXXX";
$apiKey = "YYYYYY";
$client = new Reach\Rest\Client($apiUser, $apiKey);

try {
    $msg = $client->messaging->messagingItems()->fetch("XXed11f93dc08b952027ffbc406d0868");
} catch (ReachException $e) {
    print $e->getCode();
}

print $msg->dest;


$apiUser = "XXXXXXXX";
$apiKey = "YYYYYY";

$client = new Reach\Rest\Client($apiUser, $apiKey);
$message = $client->messaging->messagingItems->send(
    '+15558675309', '+15017250604', "Hey Jenny! Good luck on the bar exam!"
);

// Print the message's SID
print $message->messageId;

// Print details about the last request
print $client->lastRequest->method;
print $client->lastRequest->url;
print $client->lastRequest->auth;
print $client->lastRequest->params;
print $client->lastRequest->headers;
print $client->lastRequest->data;

// Print details about the last response
print $client->lastResponse->statusCode;
print $client->lastResponse->body;