renatoxm/laravel-vonage-dlr-webhooks 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

renatoxm/laravel-vonage-dlr-webhooks

最新稳定版本:v2.0.1

Composer 安装命令:

composer require renatoxm/laravel-vonage-dlr-webhooks

包简介

Handle delivery receipt SMS webhooks in Laravel php framework

README 文档

README

Latest Version on Packagist Software License Tests StyleCI Total Downloads

Handle Vonage DLR (delivery receipt) SMS webhooks in Laravel php framework. Take a look at contributing.md to see a to do list.

When you make a successful request to the SMS API, it returns an array of message objects, one for each message. Ideally these will have a status of 0, indicating success. But this does not mean that your message has reached your recipients. It only means that your message has been successfully queued for sending.

Vonage's adaptive routing then identifies the best carrier for your message. When the selected carrier has delivered the message, it returns a delivery receipt (DLR).

To receive DLRs in your application, you must provide a webhook for Vonage to send them to. Alternatively, you could use the Reports API to periodically download your records, including per-message delivery status.

Installation

Via Composer

composer require renatoxm/laravel-vonage-dlr-webhooks

Publish the config file with:

php artisan vendor:publish --provider="Renatoxm\LaravelVonageDlrWebhooks\LaravelVonageDlrWebhooksServiceProvider"

This package will log all incoming webhooks to the database by default.
Run the migrations to create a vonage_dlr_webhook_logs table in the database:

php artisan migrate

Setup DLR (delivery receipt) webhooks from Vonage

Create your account at Nexmo and access the dashboard API settings.

Under SMS settings, choose SMS API, set the webhook format to POST-JSON, and configure Delivery receipts (DLR) webhooks URL like this:

https://<you-domain.com>/api/webhooks/vonage/dlr

/api/webhooks/vonage/dlr is the package's default endpoint.

You may change the /api/webhooks/vonage/dlr endpoint to anything you like.
You can do this by changing the path key in the config/laravel-vonage-dlr-webhooks.php file.

Events

Whenever a webhook call comes in, this package will fire a LaravelVonageDlrWebhooksCalled event.
You may register an event listener in the EventServiceProvider:

/**
 * The event listener mappings for the application.
 *
 * @var array
 */
protected $listen = [
    LaravelVonageDlrWebhooksCalled::class => [
        YourListener::class,
    ],
];

Example of a listener:

<?php

namespace App\Listeners;

use Renatoxm\LaravelVonageDlrWebhooks\Events\LaravelVonageDlrWebhooksCalled;

class YourListener
{
    /**
     * Handle the event.
     *
     * @param  \Renatoxm\LaravelVonageDlrWebhooks\Events\LaravelVonageDlrWebhooksCalled  $event
     * @return void
     */
    public function handle(LaravelVonageDlrWebhooksCalled $event)
    {
        // Do your work here.
        // $event->err_code
        // $event->message_id
        // $event->msisdn
        // ...
    }
}

Advanced configuration

You may optionally publish the config file with:

php artisan vendor:publish --provider="Renatoxm\LaravelVonageDlrWebhooks\LaravelVonageDlrWebhooksServiceProvider" --tag="config"

Within the configuration file you may change the table name being used or the Eloquent model being used to save log records to the database.

If you want to use your own model to save the logs to the database you should extend the Renatoxm\LaravelVonageDlrWebhooks\Model\LaravelVonageDlrWebhooksModel class.

You can also exclude one or more event types from being logged to the database.
Place the events you want to exclude under the except key:

'log' => [
    ...
    'except' => [
        'open',
        ...
    ],
],

All webhook requests will be logged in the vonage_dlr_webhook_logs table.

Change log

Please see the changelog for more information on what has changed recently.

Testing

composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security issue, please email renatoxm[at]gmail[dot]com instead of using the issue tracker.

Useful Links

Acknowledgment

This package is inspired by:

forked from https://github.com/mvdnbrk/laravel-postmark-webhooks

Credits

License

MIT. Please see the license file for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固