本特诺/bento-laravel-sdk

Bento的Laravel SDK

1.0.1 2024-09-25 05:42 UTC

This package is auto-updated.

Last update: 2024-09-25 05:43:24 UTC


README

Tests

🍱 在您的Laravel项目中发送电子邮件的简单方式!

👋 如需个性化支持,请发推文至 @bento 或发送电子邮件至 jesse@bentonow.com

🐶 由高性能SQLite(Bento客户)测试过的战斗堡垒!

⚡️ 对于事件跟踪和将数据导入Bento,请使用我们的Bento PHP SDK

❤️ 感谢@aarondfrancis的贡献。❤️ 感谢@ziptied的贡献。

需求

设置

安装

您可以通过composer安装此包

composer require bentonow/bento-laravel-sdk

配置

首先发布配置文件

php artisan vendor:publish --tag bentonow

然后在您的应用程序的config/mail.php配置文件中创建一个新的邮件发送者定义

'bento' => [
  'transport' => 'bento',
],

(备注:我们建议在开发时使用Laravel Mail Viewer(https://news.laravel.net.cn/laravel-mail-viewer)。

最后,访问您的bento配置文件并生成您的API密钥。

将API密钥添加到您的.env文件,并将您的mail_mailer设置为使用Bento

BENTO_PUBLISHABLE_KEY="{Publishable Key}"
BENTO_SECRET_KEY="{Secret Key}"
BENTO_SITE_UUID="{Site Key UUID}"
MAIL_MAILER="bento"

有关更多信息,请参阅Laravel Mail文档

使用方法

除了通过Bento发送事务性电子邮件外,此库还提供了对Bento的REST API的访问权限,这使得与Bento协同工作变得非常简单。

跟踪事件

use Bentonow\BentoLaravel\BentoConnector;
use Bentonow\BentoLaravel\Requests\CreateEvents;
use Bentonow\BentoLaravel\DataTransferObjects\EventData;

$bento = new BentoConnector();

$data = collect([
  new EventData(
    type: "$completed_onboarding",
    email: "test@example.com",
    fields: [
      "first_name" => "John",
      "last_name" => "Doe"
    ]
  )
]);

$request = new CreateEvents($data);
$response = $bento->send($request);
return $data->json();

导入订阅者

use Bentonow\BentoLaravel\DataTransferObjects\ImportSubscribersData;
  use Bentonow\BentoLaravel\BentoConnector;
  use Bentonow\BentoLaravel\Requests\ImportSubscribers;

  $bento = new BentoConnector();

  $data = collect([
    new ImportSubscribersData(
      email: "test@test.com",
      first_name: "John",
      last_name: "doe",
      tags: ["lead", "mql"],
      removeTags: ["customers"],
      fields: ["role" => "ceo"]
    ),
  ]);

  $request = new ImportSubscribers($data);
  $response = $bento->send($request);
  return $response->json();

...以及更多!

请访问我们的API文档以获取更多信息。您还可以在我们的文档中阅读关于基本使用方法

支持和反馈

如果您发现任何错误,请直接在此GitHub中提交问题。

官方API文档在https://docs.bentonow.com

许可证

MIT许可证(MIT)