getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

v2.0.0 2024-03-12 14:26 UTC

This package is not auto-updated.

Last update: 2024-07-16 16:23:18 UTC


README

Brevo's API exposes the entire Brevo features via a standardized programmatic interface. Please refer to the full documentation to learn more.

This is the wrapper for the API. It implements all the features of the API v3.

Brevo's API matches the OpenAPI v2 definition. The specification can be downloaded here.

This PHP package is automatically generated by the Swagger Codegen project and is reviewed and maintained by Brevo:

Requirements

PHP 5.6 and later

Installation & Usage

Composer

To install the bindings via Composer:

Create a composer.json file in any directory & add below code in composer.json file.

{
"require": {
"getbrevo/brevo-php": "1.x.x"
}
}

Then run below commands in the same directory

composer require getbrevo/brevo-php "1.x.x"

Further do:

  • run composer install to get these dependencies added to your vendor directory
  • add the autoloader to your application with this line: require("vendor/autoload.php")

Tests

To run the unit tests:

composer install
./vendor/bin/phpunit

Getting Started

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: api-key
$config = Brevo\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Brevo\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer');
// Configure API key authorization: partner-key
$config = Brevo\Client\Configuration::getDefaultConfiguration()->setApiKey('partner-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Brevo\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('partner-key', 'Bearer');

$apiInstance = new Brevo\Client\Api\AccountApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

try {
    $result = $apiInstance->getAccount();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AccountApi->getAccount: ', $e->getMessage(), PHP_EOL;
}

?>

Documentation for API Endpoints

All URIs are relative to https://api.brevo.com/v3

Documentation For Models

Documentation For Authorization

api-key

The API key should be passed in the request headers as api-key for authentication.

  • Type: API key
  • API key parameter name: api-key
  • Location: HTTP header

partner-key

The partner key should be passed in the request headers as partner-key along with api-key pair for successful authentication of partner (Optional).

  • Type: API key
  • API key parameter name: partner-key
  • Location: HTTP header

If you find a bug, please post the issue on Github.

As always, if you need additional assistance, drop us a note here.