您好我正在使用Nexmo API制作laravel短信通知。
我根据给定的laravel文档以及github中的内容集成了nexmo。
我的下面的代码工作正常。
Nexmo::message()->send([
'to' => 'xxxxxxx',
'from' => 'xxxxxxx',
'text' => 'Using the facade to send a message.'
]);
以上代码正在发送短信。
我需要将其整合为通知。但不幸的是return ['nexmo']
没有用。它没有在通知中点击toNexmo($notifiable)
方法。
任何人都可以帮助我。
由于
答案 0 :(得分:2)
有两种方法可以通过Nexmo发送通知 - 使用内置的通知包和使用Nexmo客户端。您已使用客户端实现它,但看起来好像您想要使用通知包,以便它调用toNexmo
。
要通过Laravel发送通知,请按以下方式发送:
Notification::send($yourUser, new SomethingNotification());
SomethingNotification
定义如下所示:
<?php
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\NexmoMessage;
class SomethingNotification extends Notification
{
public function via($notifiable)
{
return ['nexmo'];
}
public function toNexmo($notifiable)
{
return (new NexmoMessage)
->content('Some content');
}
}
答案 1 :(得分:0)
To
电话号码: public function routeNotificationForNexmo($notification)
{
return $this->phone_number;
}