Nexmo 短信 laravel 不工作
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。 -_-
基本上有一个错误的读数触发了一个名为 '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。 -_-