Nexmo / nexmo-laravel

Add Vonage functionality such as SMS and voice calling to your Laravel app with this Laravel Service Provider.
MIT License
317 stars 79 forks source link

Different Nexmo Accounts #27

Closed NichoTheMan closed 6 years ago

NichoTheMan commented 6 years ago

Hello,

I've been using your plugin for my laravel projects for a while now and it works very good, but i have a problem with the newest update in another project i'm working on.

This update lets administrators of their instance add their nexmo api key and secret to the database aswell as the numbers they want to add but as far as i can see the key and secret are only set in the .env file or the config file.

Is there a way i can use the nexmo api key and secret in the array i pass too Nexmo::message()->send();

mheap commented 6 years ago

Hey @NichoTheMan! Sorry the the delay, I've been enjoying my 🌴

If you'd like to use multiple API keys and secrets you'll need to use nexmo/client directly (github repo:

$client = new Nexmo\Client(new Nexmo\Client\Credentials\Basic(API_KEY, API_SECRET));     

You can fetch the credentials from the database and add the client instance to the container by writing your own small service provider. Here's the one that nexmo/laravel uses. This one is complicated as it has to support every possible authentication combination.

NichoTheMan commented 6 years ago

Awesome! Just what i needed. Thank you.