wickwood-llc/brevo-php

官方Brevo提供的RESTful API V3 PHP库

dev-main 2024-06-10 18:13 UTC

This package is auto-updated.

Last update: 2024-09-30 18:14:10 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上发布问题。

始终,如果您需要额外帮助,请在此联系我们。