Appearance
调用示例
本页提供 PHP 调用示例。生产环境中请不要把密钥硬编码在前端或公开仓库中。
PHP:SysKey 验证码模式
php
<?php
$url = 'https://smspanel.szczk.top/?syskey=sk_xxx&phone=13800138000&code=123456';
$response = file_get_contents($url);
$result = json_decode($response, true);
if ($result['Code'] === 'OK') {
echo '发送成功';
} else {
echo '发送失败:' . $result['Message'];
}PHP:SysKey 模板模式
php
<?php
$template_param = json_encode(['name' => '张三', 'order' => '12345'], JSON_UNESCAPED_UNICODE);
$url = 'https://smspanel.szczk.top/?syskey=sk_xxx&phone=13800138000&template_id=SMS_500650100&code=' . urlencode($template_param);
$response = file_get_contents($url);
$result = json_decode($response, true);
if ($result['Code'] === 'OK') {
echo '发送成功';
} else {
echo '发送失败:' . $result['Message'];
}PHP:AK/SK 方式
php
<?php
$params = [
'AccessKeyId' => 'your_access_key_id',
'Action' => 'SendSms',
'Format' => 'JSON',
'PhoneNumbers' => '13800138000',
'SignName' => '您的签名',
'TemplateCode' => 'SMS_123456789',
'TemplateParam' => json_encode(['code' => '123456']),
'SignatureMethod' => 'HMAC-SHA1',
'SignatureNonce' => uniqid(),
'SignatureVersion' => '1.0',
'Timestamp' => gmdate('Y-m-d\TH:i:s\Z'),
'Version' => '2017-05-25'
];
$params['Signature'] = calcSignature($params, 'your_access_key_secret', 'POST');
$ch = curl_init('https://smspanel.szczk.top/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);提示
calcSignature 需要按阿里云签名算法实现。签名计算逻辑请以阿里云官方 API 请求文档为准。