playox/brevo-php

官方Brevo提供的RESTFul API V3 PHP库

dev-main 2024-05-22 13:57 UTC

This package is auto-updated.

Last update: 2024-09-22 14:40:37 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

合作伙伴密钥应作为partner-keyapi-key配对通过请求头传递,以成功验证合作伙伴(可选)。

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

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

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