braze / sdk
Track users, send messages, export data, and more with Braze API.
Fund package maintenance!
remarkablemark
Patreon
Ko Fi
Liberapay
b.remarkabl.org/teespring
Installs: 33 399
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 1
Open Issues: 0
Requires
- php: >=8.0
- jane-php/open-api-runtime: 7.8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.22
- jane-php/open-api-3: 7.8.1
- nyholm/psr7: ^1.8
- pestphp/pest: ^1.23 || ^2.0
- php-http/guzzle7-adapter: ^1.0
- symfony/http-kernel: ^6.4
README
PHP library for Braze. Code is generated using the OpenAPI spec.
Requirements
Version
PHP >=8.0
API URL
Use the REST endpoint provisioned to your account when you log in to the dashboard:
Instance | REST Endpoint |
---|---|
US-01 | https://rest.iad-01.braze.com |
US-02 | https://rest.iad-02.braze.com |
US-03 | https://rest.iad-03.braze.com |
US-04 | https://rest.iad-04.braze.com |
US-05 | https://rest.iad-05.braze.com |
US-06 | https://rest.iad-06.braze.com |
US-08 | https://rest.iad-08.braze.com |
EU-01 | https://rest.fra-01.braze.eu |
EU-02 | https://rest.fra-02.braze.eu |
API Key
The API key can be created in your Braze dashboard.
Install
Install the package with Composer:
composer require braze/sdk
If you're missing a package providing psr/http-client-implementation
:
composer require php-http/guzzle7-adapter
Add autoloading:
require_once 'vendor/autoload.php';
Usage
Instantiate the SDK:
use Braze\Braze; $braze = new Braze('YOUR_API_URL', 'YOUR_API_KEY'); $client = $braze->client;
Send a message to your user:
use Braze\Braze; use Braze\Model\MessagesSendPostBody; $braze = new Braze('YOUR_API_URL', 'YOUR_API_KEY'); $braze->client->postMessagesSend(new MessagesSendPostBody([ 'external_user_ids' => ['your_external_user_id'], 'messages' => [ 'email' => [ 'app_id' => 'your_app_id', 'from' => 'Company <company@example.com>', 'email_template_id' => 'your_email_template_id', ], ], ]));
Handle an API error:
use Braze\Braze; $braze = new Braze('YOUR_API_URL', 'YOUR_API_KEY'); try { $braze->client->getCatalog(); } catch (Throwable $exception) { echo $exception->getMessage(); echo $exception->getCode(); }
Scripts
composer build
Generate the code:
composer build
composer clean
Delete the lib/
directory:
composer clean
composer test
Run the tests:
composer test
About This Package
This package is automatically generated by Jane.