sokolnikov911 / laravel-sendy
PHP Laravel 5+ 中 Sendy API 的服务提供者
Requires
- php: >=7.3
- illuminate/support: ^6.0
Requires (Dev)
- orchestra/testbench: ~3.7.0
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-09-09 00:35:41 UTC
README
包描述:Laravel 简单集成 Sendy API 以订阅/取消订阅用户到列表。
安装
通过 composer 安装
composer require sokolnikov911/laravel-sendy
注册服务提供者
注意!如果您使用 laravel >= 5.5 且具有包自动发现功能,此步骤是可选的。
将服务提供者添加到 config/app.php 文件的 providers 部分
sokolnikov911\LaravelSendy\ServiceProvider::class,
注册外观
在 config/app.php 文件的 aliases 部分注册包外观
'LaravelSendy' => sokolnikov911\LaravelSendy\Facades\LaravelSendy::class,
添加环境变量
SENDY_API_KEY=your-api-key SENDY_URL=your-sendy-url SENDY_LIST_ID=your-list-id
列表 ID 可在“查看所有列表”部分下名为“ID”的列中找到(加密并散列)
自定义或扩展
发布配置文件
您可以将配置文件发布以编辑变量,如果您不想使用 ENV。文件将发布到 /config/larave-sendy.php
php artisan vendor:publish --provider="sokolnikov911\LaravelSendy\ServiceProvider" --tag="config"
发布翻译
您可以将翻译发布以编辑它们。文件将发布到 /resources/lang/vendor/laravel-sendy。
注意:您可以通过在 /resources/lang/vendor/laravel-sendy/{lang}/messages.php 中创建一个新文件来扩展翻译,格式从 en 语言文件。
使用示例
在所有使用之前,请添加命名空间到文件中。
use sokolnikov911\LaravelSendy\LaravelSendy;
订阅
将新电子邮件订阅到列表。这可以用来编辑已订阅的用户。(例如更改名称)
// initialize LaravelSendy $sendy = new LaravelSendy(); // Simple email subscribe $subscribe = $sendy->subscribe('email@example.com'); // Add subscriber with email and name $subscribe = $sendy->subscribe('email@example.com', 'John Doe'); // Full subscribe method $subscribe = $sendy->subscribe($email, $name = null, $listId = null, $json = false, $customFields = []); // Response example $subscribe = [ "success" => true "message" => "You have been subscribed." ]
取消订阅示例
将电子邮件标记为从列表中取消订阅。
// initialize LaravelSendy $sendy = new LaravelSendy(); // Simple unsubscribe $unsubscribe = $sendy->unsubscribe('email@example.com'); // Full unsubscribe method $unsubscribe = $sendy->unsubscribe($email, $listId = null, $json = false); // Response example $unsubscribe = [ "success" => true "message" => "You have been unsubscribed." ]
删除示例
从列表中删除电子邮件。动作是确定的。
// initialize LaravelSendy $sendy = new LaravelSendy(); // Simple delete $delete = $sendy->delete('email@example.com'); // Full unsubscribe method $delete = $sendy->delete($email, $listId = null, $json = false); // Response example $delete = [ "success" => true "message" => "You have been deleted from the list." ]
安全
如果您发现任何与安全相关的问题,请通过电子邮件联系,而不是使用问题跟踪器。
贡献
如果您想为您的语言贡献翻译包,您可以提交一个带有从 en 语言文件 resources/lang/en/messages.php 复制的 lang 文件的 PR 请求。