morresmx/gb-php

官方Brevo提供的RESTFul API V3 PHP库

dev-main 2024-08-08 18:32 UTC

This package is auto-updated.

Last update: 2024-09-08 18:37:59 UTC


README

Brevo的API通过标准化的程序接口公开了所有的Brevo功能。请参考完整的文档来了解更多信息。

这是API的包装器。它实现了API v3的所有功能。

Brevo的API符合OpenAPI v2定义。规范可以在这里下载:此处

此PHP包由Swagger Codegen项目自动生成,并由Brevo审查和维护。

要求

PHP 5.6 及以上版本

安装与使用

Composer

通过Composer安装绑定

在任何目录中创建一个composer.json文件,并在composer.json文件中添加以下代码。

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

然后在同一目录中运行以下命令

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

进一步做

  • 运行composer install以将这些依赖添加到您的vendor目录
  • 使用以下行将自动加载器添加到您的应用程序中:require("vendor/autoload.php")

测试

要运行单元测试

composer install
./vendor/bin/phpunit

入门指南

请按照安装过程进行操作,然后运行以下命令

<?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;
}

?>

API端点文档

所有URI都是相对于https://api.brevo.com/v3

模型文档

授权文档

api-key

API密钥应作为请求头中的api-key传递以进行身份验证。

  • 类型:API密钥
  • API密钥参数名称:api-key
  • 位置:HTTP头

partner-key

合作伙伴密钥应与api-key一起作为请求头中的partner-key传递,以成功验证合作伙伴(可选)。

  • 类型:API密钥
  • API密钥参数名称:partner-key
  • 位置:HTTP头

如果您发现错误,请在Github上发布问题。

始终如一,如果您需要额外的帮助,请在此给我们留言。