[英]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.