【问题标题】:Nexmo sms laravel not workingNexmo 短信 laravel 不工作
【发布时间】:2015-11-09 12:41:10
【问题描述】:

基本上有一个错误的阅读触发了一个名为“AbnormalReadingWasTaken”的事件,我在“EventServiceProviders”的“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);
    }
} 

【问题讨论】:

    标签: php laravel vonage


    【解决方案1】:

    抱歉给您带来的麻烦,代码没有问题,错误是因为错误的api_key,我的错误不敢相信我实际上复制了错误的api_key。 -_-

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-27
      • 2017-06-23
      相关资源
      最近更新 更多