I want to implement twillio API in Yii2.
On submit form SMS should be sent.
I placed all twillio library code in advanced yii2 app in :
rr.lcl/library/twilli_lib/
rr.lcl是我的根文件夹(高级)
Here is my function:
public function actionSendtestsms($id) {
require($_SERVER['DOCUMENT_ROOT'].'/rr.lcl/library/twilio-php-master/Services/Twilio.php')
$client = new Services_Twilio($account_sid, $auth_token);
}
如何在Yii2控制器功能中包含外部php calss文件。
答案 0 :(得分:0)
通过Composer安装Twillio PHP sdk(在Yii2运行的根目录中):
php /path/to/composer.phar require 'twilio/sdk:4.2.1'
它已添加到Yii2自动加载的库,然后在您的操作中执行:
public function actionSendtestsms($id) {
$client = new Services_Twilio($account_sid, $auth_token);
}