基本的に、「EventServiceProviders」の「AbnormalReadingWasTaken」の下に 2 つのリスナーを登録した「AbnormalReadingWasTaken」というイベントをトリガーする誤った読み取りがあり、最初のリスナー「AddReadingsToAlertsTable」は正常に動作しますが、他のリスナー「SendAlertSMS」は機能しません。仕事に。私は何が欠けていますか、誰かがこれを手伝ってくれますか? これは nexmo SMS の 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);
}
}