定制 ahmedsalah/kenda-communication-plugin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ahmedsalah/kenda-communication-plugin

最新稳定版本:0.4

Composer 安装命令:

composer require ahmedsalah/kenda-communication-plugin

包简介

kenda-communication-plugin

README 文档

README

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

Overview

The Kenda Communication Plugin is a Laravel package designed to facilitate communication between your Laravel application and WhatsApp services. It provides a structured way to register devices, websites, and functions, ensuring secure and seamless integration with remote servers.

Installation

You can install the package via Composer:

composer require ahmedsalah/kenda-communication-plugin

Configuration

Publish the configuration file using the following command:

php artisan vendor:publish --tag="kenda-communication-plugin-config"

This will create a configuration file containing:

return [

    'api_key' => env('KENDA_COMMUNICATION_PLUGIN_API_KEY', 'kn-...'),
    'from_phone' => env('KENDA_COMMUNICATION_PLUGIN_FROM_PHONE', '254712345678'),
    
    'public_key_path' => env('KENDA_COMMUNICATION_PLUGIN_PUBLIC_KEY_PATH', 'public_key_server.kendaKey'),

    'enable_user_resolving' => env('KENDA_COMMUNICATION_PLUGIN_ENABLE_USER_RESOLVING', true),
    'enable_guest_user' => env('KENDA_COMMUNICATION_PLUGIN_ENABLE_GUEST_USER', true),

    'user_model' => env('KENDA_COMMUNICATION_PLUGIN_USER_MODEL', 'App\Models\User'),
    'user_phone_number_column' => env('KENDA_COMMUNICATION_PLUGIN_USER_PHONE_NUMBER_COLUMN', 'phone_number'),

    'functions' => [
        'example_function' => 'App\KendaCommunicationPlugin\Functions\ExampleFunction',
    ],
];

Usage

1. Register a New Device

To begin, you must register a WhatsApp number (Device) with the server.

2. Register Your Website

Once the device is registered, register your website on the server. This allows your website to communicate with the API and receive user requests.

3. Register Your Functions

Functions must be registered on the server to allow your Laravel application to execute them remotely.

4. Map Local Functions to Remote Server Functions

Each registered function must be mapped to a local function in your Laravel application.

Generate a function file:

php artisan kenda:generate-function

Then, map the function in the config file:

return [
    'functions' => [
        'createUser' => 'App\KendaCommunicationPlugin\Functions\CreateUser',
        'writeArticle' => 'App\KendaCommunicationPlugin\Functions\WriteArticle',
    ],
];

Additional Features

Sending WhatsApp Messages

You can send WhatsApp messages directly to users using the following function:

KendaCommunicationPlugin::sendWhatsappMessage(string $targetPhone, string $message);

This feature is useful for notifications and reminders. However, avoid excessive messaging to prevent getting blocked by WhatsApp.

Testing

Run the test suite using:

composer test

Changelog

Refer to the CHANGELOG for a record of recent changes.

Credits

License

This package is open-source under the MIT License. See LICENSE for details.

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-06