PHP code example of braze / sdk

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

    

braze / sdk example snippets




use Braze\Braze;

$braze = new Braze('YOUR_API_URL', 'YOUR_API_KEY');

$client = $braze->client;

use Braze\Braze;
use Braze\Model\MessagesSendPostBody;
use Braze\Model\MessagesSendPostBodyMessages;

$braze = new Braze('YOUR_API_URL', 'YOUR_API_KEY');

$body = new MessagesSendPostBody();
$body->setExternalUserIds(['your_external_user_id']);

$messages = new MessagesSendPostBodyMessages();
$messages->setEmail([
    'app_id' => 'your_app_id',
    'from' => 'Company <[email protected]>',
    'email_template_id' => 'your_email_template_id',
]);
$body->setMessages($messages);

$response = $braze->client->postMessagesSend($body)->getBody();

use Braze\Braze;

$braze = new Braze('YOUR_API_URL', 'YOUR_API_KEY');

try {
    $response = $braze->client->getCatalog()->getBody();
} catch (Throwable $exception) {
    echo $exception->getMessage();
    echo $exception->getCode();
}