laravel-notification-channels / twilio

Twilio notifications channel for Laravel

Home Page:https://laravel-notification-channels.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sender name is not Alphanumeric, number instead

hazem-taha opened this issue · comments

Hello,

I'm using (Laravel v6, package version: 3.1.2)

Using code like this sends the from name as String as needed, but using notification and TwilioChannel::class as channel sends the from name is the twilio's registered number not a string.

Before it is working perfectly, but now it is not, I believe it happened after upgrading twilio/sdk package

// Your Account SID and Auth Token from twilio.com/console
        $sid = env('TWILIO_SID');
        $token = env('TWILIO_TOKEN');
        $client = new Client($sid, $token);

        $validator = Validator::make($request->all(), [
            'numbers' => 'required',
            'message' => 'required'
        ]);

        if ($validator->passes()) {

            $numbers_in_arrays = explode(',', $request->input('numbers'));

            $message = $request->input('message');
            $count = 0;

            foreach ($numbers_in_arrays as $number) {
//              Notification::route('twilio', $number)->notify(new \App\Notifications\SomeNotification());

                $count++;

                $client->messages->create(
                    $number,
                    [
                        'from' => 'Test Sender',
                        'body' => $message,
                    ]
                );
            }

            return back()->with('success', $count . " messages sent!");

        } else {
            return back()->withErrors($validator);
        }