如何将 OVH Api 与 Laravel 一起使用
How to use OVH Api with Laravel
我正在开发一个向我们的客户发送短信的应用程序。
我正在查看文档 (https://docs.ovh.com/fr/sms/envoyer_des_sms_avec_lapi_ovh_en_php/) => 它是法语的。
他们正在使用 PHP 包装器,但我真的不知道如何将 API 集成到我的 Laravel 项目中。
有人知道它是如何工作的吗?
首先,安装包
composer require ovh/php-ovh-sms
然后,在控制器上,您可以按照文档中的说明轻松使用API。
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);
有一个专门针对此提供商的 Laravel 通知渠道,这将使整个过程变得更加容易,它将允许您使用 Laravel 的内置通知功能而无需编写提供商特定代码。
我正在开发一个向我们的客户发送短信的应用程序。
我正在查看文档 (https://docs.ovh.com/fr/sms/envoyer_des_sms_avec_lapi_ovh_en_php/) => 它是法语的。
他们正在使用 PHP 包装器,但我真的不知道如何将 API 集成到我的 Laravel 项目中。
有人知道它是如何工作的吗?
首先,安装包
composer require ovh/php-ovh-sms
然后,在控制器上,您可以按照文档中的说明轻松使用API。
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);
有一个专门针对此提供商的 Laravel 通知渠道,这将使整个过程变得更加容易,它将允许您使用 Laravel 的内置通知功能而无需编写提供商特定代码。