mofing / aliyun-dysms
DySms plugin for CakePHP
Installs: 27
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:cakephp-plugin
Requires
- php: >=5.6.0
- cakephp/cakephp: ^3.4
This package is auto-updated.
Last update: 2024-12-15 15:05:59 UTC
README
Aliyun SMS SDK for CakePHP
-
https://ak-console.aliyun.com/ 从这里找到ACCESS_ID和ACCESS_KEY ,如果没有,生成一个
-
修改/config/paths.php,最后加入阿里云访问认证,也可以把ACCESS_ID和ACCESS_KEY设置到php的环境变量中
/** 阿里云Access Key ID */ putenv('ACCESS_ID=aaa');
/** 阿里云 ACCESS KEY */ putenv('ACCESS_KEY=bbb');
SmsComponent中,用下面的代码来获取值
$accessKeyId = getenv("ACCESS_ID"); $accessKeySecret = getenv("ACCESS_KEY");
- PagesController控制器中,引入DySms模块
var $components = [ 'DySms.Sms' ];
- 调用发送短信方法
public function index(){ $this->Sms->send(); }