Closed muhamadhhassan closed 5 years ago
I struggled with this too. The issue is that this "Twilio notifications channel" under "vendor/laravel-notification-channels/twilio" uses the Twillio SDK under "vendor/twilio/sdk/Twilio/" for API call transport. The SDK is maintained by a separate team and unfortunately it does not throw Laravel exceptions.
Here is what I had to do to work around the issue:
Quick workaround: Edit the Rest Client Class to report to your storage/logs/laravel.log on the request / response to Twilio API endpoint.
Longer-Term workaround: Use composer to override the default Rest\Client Class with your customized class that does some conditional reporting based upon a configuration in your .env file. (1) Step 1. Create this folder and customized class in your Laravel App app\MyVendor\twilio\Rest\Client.php (2) Step 2. Update Composer.json to exclude this Class namespace "autoload": { "exclude-from-classmap": [ "vendor/twilio/sdk/Twilio/Rest/Client.php" ] },
(3) Step 3. Tell composer where to find your custom class using psr-4 "autoload": { "psr-4": { "App\": "app/", "Twilio\": "app/MyVendor/twilio/" }, }, (4) Step 4: Refresh composer composer dump-autoload (5) Step 5. Execute your code and observe logs for the call response from Twillio (6) Step 6. Grab a coffee
@lancemitchell Thank you for your reply, the solution you suggested worked and I can get the request options now.
I found that the request is made to this endpoint https://api.twilio.com/2010-04-01/Accounts/{account_sid}/Messages.json
which retrieves all the messages sent by my account!
@lancemitchell which kind of exceptions are failing to capture?
You mention
it does not throw Laravel exceptions
but what would they be? Can we capture the Twilio Exception and re-throw them with Laravel Notification compatible ones?
On laravel 5.6 as well. Does not work out sending the sms.
Should be fixed.
Doesn't work in laravel 9
I can confirm that is not working for me neither in Laravel 9.38.0 (with laravel-notification-channels/twilio 3.2.0 and twilio/sdk 6.43.1) . No exceptions, but the SMS is not sent. Nothing on my Twilio logs neither (as if it never reached Twilio).
I am trying to use the release
2.0.6
with a laravel 5.5 app I get no exceptions but the SMS was not sentservice.php
Notification Class
In User.php