PHP SDK
安装
使用 Composer 安装泛玩短信 PHP SDK:
bash
composer require fanwan/sms快速开始
创建客户端实例:
php
$client = new Fanwan\SMS\Client('YOUR_ACCESS_KEY');发送短信
使用 send 方法发送短信:
php
$result = $client->send([
'to' => '13800138000',
'signature' => '泛玩短信',
'templateId' => 'welcome',
'templateData' => [
'name' => '张三',
],
]);
echo $result['messageId'];发送验证码
使用验证码模板快速发送验证码短信:
php
$result = $client->send([
'to' => '13800138000',
'signature' => '泛玩短信',
'templateId' => 'verify_code',
'templateData' => [
'code' => '1234',
],
]);
echo $result['messageId'];