realrashid/laravel-zoho-cliq

一个用于集成 Zoho Cliq 的 Laravel 扩展包,允许您从 Laravel 应用程序中无缝发送消息、通知和丰富内容。

v1.0.0 2024-08-11 12:45 UTC

This package is auto-updated.

Last update: 2024-09-11 13:06:59 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

简介

Laravel Zoho Cliq 是一个设计用来无缝集成 Zoho Cliq 的 Laravel 扩展包,允许您从 Laravel 应用程序中直接发送消息和通知。无论您需要与单个用户通信还是向频道广播消息,此扩展包都提供了一个易于使用的界面,以便与 Zoho Cliq 的 API 进行交互。

安装

要开始使用,请通过 Composer 安装该扩展包

composer require realrashid/laravel-zoho-cliq

然后,发布配置文件

php artisan cliq:install

配置

安装扩展包后,您需要配置 OAuth 凭据和默认设置。

获取客户端 ID 和密钥

  1. 前往 Zoho API 控制台
  2. 如果您没有任何客户端,请点击 开始使用 按钮。
  3. 将出现一个模态窗口。选择 自用客户端 并点击 创建
  4. 您将收到提示 "您确定要启用自用客户端吗?" 点击 确定
  5. 复制提供的 客户端 ID客户端密钥
  6. 将它们添加到您的 .env 文件
CLIQ_API_BASE_URL=https://cliq.zoho.com/api/v2
CLIQ_CLIENT_ID=your-client-id
CLIQ_CLIENT_SECRET=your-client-secret
CLIQ_DEFAULT_CHANNEL=your-default-channel
CLIQ_DEFAULT_SEND_TO=buddies

使用

以下是使用此扩展包与 Zoho Cliq 交互的一些示例

向多个用户发送消息

向多个 Zoho Cliq 用户发送消息

// Route to send a message to multiple users
Route::get('/send-buddy-message', function () {
    $response = Cliq::to(['user1@example.com', 'user2@example.com'])
        ->send("Hello team! This is a message from Laravel.");

    return response()->json($response);
});

向单个用户发送消息

向单个 Zoho Cliq 用户发送消息

// Route to send a message to a single user
Route::get('/send-single-buddy-message', function () {
    $response = Cliq::to('user@example.com')
        ->send("Hi there! This is a personal message from Laravel.");

    return response()->json($response);
});

带有卡片的发送消息

向 Zoho Cliq 频道发送带有卡片的丰富消息

// Route to send a message with a card
Route::get('/send-card-message', function () {
    $response = Cliq::toChannel()->to('alerts')
        ->card(
            'New Feature Released!',
            'https://example.com/image.jpg',
            'https://example.com/image.jpg',
            'modern-inline',
            'Release Bot',
            [
                [
                    'label' => 'Learn More',
                    'hint' => 'Click to learn more about the feature',
                    'action_type' => 'open.url',
                    'web_url' => 'https://example.com/feature',
                ],
                [
                    'label' => 'Feedback',
                    'hint' => 'Provide feedback on the new feature',
                    'action_type' => 'open.url',
                    'web_url' => 'https://example.com/feedback',
                ]
            ]
        )
        ->send("We are excited to announce the release of our new feature!");

    return response()->json($response);
});

向频道发送消息

向特定的 Zoho Cliq 频道发送消息

// Route to send a message to a channel
Route::get('/send-message-channel', function () {
    $response = Cliq::toChannel()->to('general')
        ->send("Good morning, everyone! Here’s the latest update from Laravel.");

    return response()->json($response);
});

测试

使用 Composer 运行测试

composer test

变更日志

有关最新更改,请参阅 变更日志

贡献

我们欢迎贡献!请参阅 贡献指南 以获取更多信息。

安全漏洞

如果您发现任何安全漏洞,请通过电子邮件 realrashid@gmail.com 负责任地向我们报告。我们将尽快解决这个问题。

致谢

支持我的工作

如果您认为这个扩展包很有用,并想支持我的工作,您可以给我买杯咖啡。您的支持有助于使此项目保持活力和繁荣。谢谢!

Buy me a coffee

许可

此扩展包受 MIT 许可证的许可。有关更多信息,请参阅 许可文件


用爱从巴基斯坦制作