All Projects → immobiliare → braze-php-sdk

immobiliare / braze-php-sdk

Licence: MIT license
A PHP client to interact with Braze API

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to braze-php-sdk

Alpaca
Given a web API, Generate client libraries in node, php, python, ruby
Stars: ✭ 2,447 (+16213.33%)
Mutual labels:  api-client, client-library
youtube-deno
A Deno client library of the YouTube Data API.
Stars: ✭ 30 (+100%)
Mutual labels:  api-client, client-library
php-abraflexi
PHP Based Library for easy interaction with czech accounting system FlexiBee.
Stars: ✭ 15 (+0%)
Mutual labels:  api-client
Clamor
The Python Discord API Framework
Stars: ✭ 14 (-6.67%)
Mutual labels:  api-client
cells-client
Command line client to communicate with cells REST api.
Stars: ✭ 17 (+13.33%)
Mutual labels:  api-client
strava
PHP Class for the Strava API (v3)
Stars: ✭ 117 (+680%)
Mutual labels:  api-client
bitflyer-api-dotnet-client
bitFlyer HTTP APIs Client Library for .NET (C#)
Stars: ✭ 23 (+53.33%)
Mutual labels:  api-client
WikidataR
An R package for the Wikidata API
Stars: ✭ 49 (+226.67%)
Mutual labels:  api-client
backlog kit
Client library for the Nulab's Backlog API version 2 written in Ruby.
Stars: ✭ 28 (+86.67%)
Mutual labels:  api-client
nis-python-client
Python client for NEM NIS API (https://nemproject.github.io). XEM\NEM\Crypto
Stars: ✭ 16 (+6.67%)
Mutual labels:  api-client
jacky
🐄 HTTP JSON API Client for Laravel & Lumen
Stars: ✭ 17 (+13.33%)
Mutual labels:  api-client
tempo-api-python-client
Python bindings for Tempo - https://apidocs.tempo.io/
Stars: ✭ 17 (+13.33%)
Mutual labels:  api-client
DummyJSON
DummyJSON provides different types of REST Endpoints filled with JSON data which you can use in developing the frontend with your favorite framework and library without worrying about writing a backend.
Stars: ✭ 213 (+1320%)
Mutual labels:  api-client
goql
A GraphQL client package written in Go.
Stars: ✭ 17 (+13.33%)
Mutual labels:  client-library
pinboard.net
Fully featured API wrapper for pinboard.in
Stars: ✭ 21 (+40%)
Mutual labels:  api-client
node-meraki-dashboard
A modern node.js client library for using the Meraki Dashboard API.
Stars: ✭ 20 (+33.33%)
Mutual labels:  client-library
yelp-ios
No description or website provided.
Stars: ✭ 61 (+306.67%)
Mutual labels:  api-client
JSON-API-Client
Abstract client-side php implementation of the json api specification (jsonapi.org)
Stars: ✭ 17 (+13.33%)
Mutual labels:  api-client
my api client
A framework of Web API Client. Provides features error handling, retrying, pagination and so on.
Stars: ✭ 19 (+26.67%)
Mutual labels:  api-client
v-shopware-api-client
The reliable way to import and update a bazillion products.
Stars: ✭ 20 (+33.33%)
Mutual labels:  api-client

Braze PHP SDK

CI codecov Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

A PHP client to interact with Braze API

Braze offers a cloud-based customer engagement platform for multichannel marketing. This SDK allows you to integrate its REST API into a PHP application.

Table of Contents

Features

  • Explicit representation of the API contract to write requests easily using the IDE autocomplete
  • Formal validation (strict and non-strict) of requests
  • Dry-run mode to simulate requests and validate them without actually performing calls
  • Ability to use any http client via an adapter. For PSR-18 compatible clients and the Symfony client, adapters are included in the SDK
  • Parallel API calls supported if the http client allows it (for example the Symfony one)

Install

Add the SDK as a dependency running:

composer require immobiliarelabs/braze-sdk

If not already included in your project, to make http requests, you need to install any combination of packages that implements:

for example by installing symfony/http-client and nyholm/psr7 you are ready to use the SDK, also with parallel requests.

Alternatively, it is also possible to use any http client by creating the appropriate adapter.

Usage

Example

Before instantiating the SDK it is necessary to create the http client and its adapter.

use ImmobiliareLabs\BrazeSDK\ClientAdapter\SymfonyAdapter;
use Symfony\Component\HttpClient\HttpClient;

$client = HttpClient::create();
$adapter = new SymfonyAdapter($client);

This example is for the Symfony http client, but the flow is the same whether you are using a PSR-18 client or a custom one. Then you can create the SDK instance.

use ImmobiliareLabs\BrazeSDK\Braze;
use ImmobiliareLabs\BrazeSDK\Region;

$braze = new Braze($adapter, 'my-api-key', Region::EU01);

Now you can start making requests by creating one and passing it to the appropriate endpoint.

use ImmobiliareLabs\BrazeSDK\Object\Event;
use ImmobiliareLabs\BrazeSDK\Request\Users\TrackRequest;

$event = new Event();
$event->external_id = 'user-id';
$event->app_id = 'app-id';
$event->name = 'event-name';
$event->time = new \DateTimeImmutable();
$event->properties = ['property' => 'property-value'];

$request = new TrackRequest();
$request->events = [$event];

$response = $braze->users()->track($request, false);

You can see a few complete examples in the repository.

Endpoints

Endpoints are organized by url prefix. The SDK supports all the Braze endpoints:

  • users
  • campaigns
  • canvas
  • messages
  • content_blocks
  • templates
  • email
  • events
  • feed
  • purchases
  • sessions
  • sends
  • transactional
  • subscription

Validation and dry-run

The SDK does a formal validation of the request before executing it. It is however possible to disable it completely:

$braze->setValidation(false);

or just the strict one, since Braze partially executes requests when possible:

$braze->setValidation(true, false);

By default, the SDK performs strict validation.

If you want to validate your requests without sending them to Braze you can enable dry-run mode:

$braze->setDryRun(true);

HTTP client adapter

If, in your project, you already have a http client which does not implement one of the two supported interfaces (Symfony and PSR18), and you don't want to install another one, just define an adapter that implements the ImmobiliareLabs\BrazeSDK\ClientAdapter\ClientAdapterInterface interface, and use it when instantiate the SDK.

Parallel requests

If the chosen http client supports asynchronous calls, you can exploit that to make parallel requests to Braze in this way:

$response1 = $braze->users()->track($request1, true);
$response2 = $braze->users()->track($request2, true);

$braze->flush();

The response objects will be filled with the values obtained only after the call to flush.

Compatibility

Version Status PHP compatibility
1.x maintained >=7.2
2.x maintained >=8.0

Requirements

  • ext-json

Powered Apps

Braze PHP SDK was created by the PHP team at ImmobiliareLabs, the Tech dept of Immobiliare.it, the #1 real estate company in Italy.

We are currently using this SDK to stay in touch with our users.

If you are using Braze PHP SDK in production drop us a message.

Contributing

Any questions, bug reports or suggestions for improvement are very welcome. See the contributing file for details on how to contribute.

Changelog

Please refer to the changelog notes.

License

Braze PHP SDK is licensed under the MIT license.
See the LICENSE file for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].