PHP code example of outkit / php-client

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

    

outkit / php-client example snippets


// Use autolading to be able to use our classes without explicitly requiring them
(array(
    "key" => "",        // Fill in your API key
    "secret" => "",     // Fill in your API secret
    "passphrase" => ""  // Fill in your API passphrase (not your personal password)
));

// Construct a message record
$messageRecord = array(
    "type" => "email",                   // Message type - 'email' and 'sms' currently supported
    "project" => "my-project",           // Project identifier
    "subject" => "Welcome, Jane!",       // Email subject (optional, can also be set in the template or omitted for SMS messages)
    "template" => "my-template",         // Template identifier
    "to" => "[email protected]",     // Recipient address (and optional name)
    "from" => "[email protected]",  // Sender address (and optional name)
    "data" => array(
        "name" => "John Doe",
        // ...
        // Add the values for any variables used in the template here
    ),
);

// Then submit it
$message = $client->createMessage($messageRecord);


$message = $client->getMessage("some-id");

object(stdClass){
    "type" => "email",
    "id" => "578b072e-79e4-441e-b696-784aa744bf6e",
    "project" => "my-project",
    "template" => "my-welcome",
    "to" => "[email protected]",
    "from" => "[email protected]",
    "status" => "received",
    "subject" => "Welcome, Jane!",
    "html_body" => null,
    "text_body" => null,
    "data" => null,
    "created_at" => "2017-07-21T19:17:35.383277Z",
    "failed_at" => null,
    "queued_at" => null,
    "delivered_at" => null,
    "done" => false,
}

composer  composer.phar 
json
{
  "utkit/php-client": "*"
  }
}