Php Laravel Nexmo,使用通知时凭据不正确

Php Laravel Nexmo,使用通知时凭据不正确,php,laravel,laravel-5,laravel-queue,laravel-5.5,Php,Laravel,Laravel 5,Laravel Queue,Laravel 5.5,我想用Nexmo和Laravel发送一些短信。 当我直接通过路由发送消息时,它工作正常: Route::get('/sms/send/{to}', function(\Nexmo\Client $nexmo, $to){ $message = $nexmo->message()->send([ 'to' => $to, 'from' => '@me', 'text' => 'Sending SMS from L

我想用Nexmo和Laravel发送一些短信。 当我直接通过路由发送消息时,它工作正常:

Route::get('/sms/send/{to}', function(\Nexmo\Client $nexmo, $to){
    $message = $nexmo->message()->send([
        'to' => $to,
        'from' => '@me',
        'text' => 'Sending SMS from Laravel. yay!!!'
    ]);
    Log::info('sent message: ' . $message['message-id']);
});
但是,当我尝试使用通知类来识别sms时,我会收到错误“错误凭据”。我一直在关注以下官方文件:

以下是扩展通知的类:

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\NexmoMessage;

class KeepGoing extends Notification
{
    use Queueable;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['nexmo'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toNexmo($notifiable)
    {

        return (new NexmoMessage)
                ->content('Your SMS message content');

    }

您没有提到在收到错误时如何发送通知,但如果使用队列,则应确保运行

php artisan queue:restart

要使流程在队列中运行,请查看您的更改(例如modified.env或config)

结果表明错误是由一个愚蠢的错误引起的,我在config/services.php中弄乱了nexmo配置:

  'nexmo' => [
      'key' => env('NEXMO_KEY'),
      'secret' => env('NEXMO_SECRET'),
      'sms_from' => '15556666666',
  ],

我把实际的钥匙和秘密放在上面…

谢谢你的回答。我没有使用队列。我用一些额外的信息编辑了这个问题。那么,如果你在路线行动中发送短信,短信是如何发送的呢?一开始我在services.php中没有任何关于nexmo的内容,这似乎是不可能的。此时,从config/nexmo.php获取的key/secret。在看到另一个类似的指南后,我将配置添加到services.php。所以我猜route版本直到我将配置添加到services.php时才起作用。。。
php artisan queue:restart
  'nexmo' => [
      'key' => env('NEXMO_KEY'),
      'secret' => env('NEXMO_SECRET'),
      'sms_from' => '15556666666',
  ],