keepsuit / laravel-zoho-campaigns
从 Laravel 管理Zoho Campaigns
0.3.1
2024-05-31 14:50 UTC
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.5
- illuminate/contracts: ^9.0 || ^10.0 || ^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.8
- laravel/pint: ^1.13
- mockery/mockery: ^1.6
- nunomaduro/collision: ^6.0 || ^7.0 || ^8.0
- orchestra/testbench: ^7.0 || ^8.0 || ^9.0
- pestphp/pest: ^1.23 ||^2.0
- pestphp/pest-plugin-laravel: ^1.4 || ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- spatie/laravel-ray: ^1.26
README
本包提供了一个简单的方式来与 Zoho Campaigns API 交互。
目前仅支持以下功能
- 将联系人订阅到列表
- 从列表中取消联系人的订阅
- 从列表中获取订阅者
- 获取列表的订阅者数量
安装
您可以通过 composer 安装此包
composer require keepsuit/laravel-zoho-campaigns
您可以使用以下命令发布和运行迁移
php artisan vendor:publish --tag="campaigns-migrations"
php artisan migrate
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="campaigns-config"
这是发布后的配置文件内容
return [ /** * The driver to use to interact with Zoho Campaigns API. * You may use "log" or "null" to prevent calling the * API directly from your environment. */ 'driver' => env('CAMPAIGNS_DRIVER', 'api'), /** * Zoho datacenter region to use. * Available regions: us, eu, in, au, jp, cn */ 'region' => env('CAMPAIGNS_REGION'), /** * Zoho api client. * Run php artisan campaigns:setup and follow the instructions to generate an api client. */ 'client_id' => env('CAMPAIGNS_CLIENT_ID'), 'client_secret' => env('CAMPAIGNS_CLIENT_SECRET'), /** * The listName to use when no listName has been specified in a method. */ 'defaultListName' => 'subscribers', /** * Here you can define properties of the lists. */ 'lists' => [ /** * This key is used to identify this list. It can be used * as the listName parameter provided in the various methods. * * You can set it to any string you want and you can add * as many lists as you want. */ 'subscribers' => [ /** * A Zoho campaigns list key. * https://www.zoho.com/campaigns/help/developers/list-management.html * You can find this value from Zoho campaigns dashboard under: * Contacts > Manage Lists > "Your list" > Setup */ 'listKey' => env('CAMPAIGNS_LIST_KEY'), ], ], ];
首次设置
这应该在生产环境中也完成,因为令牌被保存在数据库中。运行以下命令并遵循指示
php artisan campaigns:setup
使用方法
将联系人订阅到列表
use Keepsuit\Campaigns\Facades\Campaigns; Campaigns::subscribe('user_a@example.com'); // with additional details: Campaigns::subscribe('user_a@example.com', contactInfo: [ 'First Name' => 'John', 'Last Name' => 'Doe', ]); // on a specific list: Campaigns::subscribe('user_a@example.com', contactInfo: [], listName: 'listName'); // if user previously unsubscribed from the list, you can resubscribe them (it support the same parameters as subscribe): Campaigns::resubscribe('user_a@example.com');
从列表中取消联系人的订阅
use Keepsuit\Campaigns\Facades\Campaigns; Campaigns::unsubscribe('user_a@example.com'); // from a specific list: Campaigns::unsubscribe('user_a@example.com', listName: 'listName');
从列表中获取订阅者
use Keepsuit\Campaigns\Facades\Campaigns; // This method returns a LazyCollection and will fetch additional pages when needed. // You can filter by status and sort the results. Campaigns::subscribers(status: 'active', sort: 'desc'); // from a specific list: Campaigns::subscribers(listName: 'listName');
获取列表的订阅者数量
use Keepsuit\Campaigns\Facades\Campaigns; // You can filter by status. Campaigns::subscribersCount(status: 'active'); // from a specific list: Campaigns::subscribersCount(listName: 'listName');
测试
composer test
变更日志
请参阅 变更日志 了解最近更改的详细信息。
贡献
请参阅 贡献指南 了解详细信息。
安全漏洞
请查看 我们的安全策略 了解如何报告安全漏洞。
鸣谢
许可证
MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。