[英]Nexmo sms laravel not working
基本上有一个错误的读取触发了一个名为“AbnormalReadingWasTaken”的事件,我在我的“EventServiceProviders”中的“AbnormalReadingWasTaken”下注册了两个监听器,其中第一个监听器“AddReadingsToAlertsTable”工作正常,但另一个监听器“SendAlertSMS”似乎没有上班。 我错过了什么,有人可以帮助我吗? 我相信这与 nexmo 短信的 curl 脚本有关吗?
<?php
namespace App\Listeners;
use App\Events\AbnormalReadingWasTaken;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class SendAlertSMS
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param AbnormalReadingWasTaken $event
* @return void
*/
public function handle(AbnormalReadingWasTaken $event)
{
$url = 'https://rest.nexmo.com/sms/json?' . http_build_query([
'api_key' => 'xxxxx',
'api_secret' => 'xxxxx',
'to' => 'xxxxx',
'from' => 'xxxxxx',
'text' => 'Hello from Nexmo'
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
}
}
很抱歉造成的麻烦,代码没有问题,错误是因为api_key错误,我的错误无法相信我实际上复制了错误的api_key。 -_-
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.