1

基本的に、「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);
    }
} 
4

1 に答える 1

1

トラブルが発生して申し訳ありません。コードに問題はありません。エラーは間違った api_key が原因でした。私の間違いは、実際に間違った api_key をコピーしたとは信じられません。-_-

于 2015-11-09T17:56:36.137 に答える