Search code examples
phplaravelovh

How to use OVH Api with Laravel


I'm working on an application that sends SMS to the customers we got.

I'm currently looking the doc (https://docs.ovh.com/fr/sms/envoyer_des_sms_avec_lapi_ovh_en_php/) => it's in french.

They're using a PHP Wrapper, but I really don't know how I can integrate the API to my Laravel Project.

Does someone know how it's working ?


Solution

  • First of all, install the package

    composer require ovh/php-ovh-sms
    

    Then, on the controller, you can use the API easily as stated in the documentation.

    use \Ovh\Sms\SmsApi;
    
    // Informations about your application
    // You may set them to 'NULL' if you are using
    // a configuraton file
    $applicationKey = "your_app_key";
    $applicationSecret = "your_app_secret";
    $consumerKey = "your_consumer_key";
    $endpoint = 'ovh-eu';
    
    // Init SmsApi object
    $Sms = new SmsApi( $applicationKey, $applicationSecret, $endpoint, $consumerKey );
    
    // Get available SMS accounts
    $accounts = $Sms->getAccounts();
    dd($accounts);