简体   繁体   English

Nexmo 短信 laravel 不起作用

[英]Nexmo sms laravel not working

Basically there is a faulty reading which triggers an event called 'AbnormalReadingWasTaken' which I've registered two listeners under 'AbnormalReadingWasTaken' in my 'EventServiceProviders' where the first listener 'AddReadingsToAlertsTable' works fine however the other listener 'SendAlertSMS' doesn't seem to work.基本上有一个错误的读取触发了一个名为“AbnormalReadingWasTaken”的事件,我在我的“EventServiceProviders”中的“AbnormalReadingWasTaken”下注册了两个监听器,其中第一个监听器“AddReadingsToAlertsTable”工作正常,但另一个监听器“SendAlertSMS”似乎没有上班。 What am I missing, can anyone help me with this?我错过了什么,有人可以帮助我吗? I believe this has something to do with the curl script of the nexmo sms?我相信这与 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);
    }
} 

Sorry for the trouble caused, nothing wrong with the code, the error was because of the wrong api_key, my mistake cant believe I actually copied the wrong api_key.很抱歉造成的麻烦,代码没有问题,错误是因为api_key错误,我的错误无法相信我实际上复制了错误的api_key。 -_- -_-

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM