讓您全面了解并上手億速云產品
常見入門級使用教程
對外 API 開發文檔中心
您歷史提交的工單
您的每一條意見,我們都嚴謹處理
您的每一條建議,我們都認真對待
方法一:
使用億速云短信擴展 https://github.com/yisu-cloud/sms
方法二:
<?php
function sendSms() {
$url = "https://api.yisu.com/sms/sendSms";
$accessId = "*****";
$accessSecret = "*****";
$params = [
"timestamp" => time(),
"nonce" => mt_rand(0, 99999999),
"accessId" => $accessId
];
$params["phone"] = "13800000000";
$params["templateCode"] = 100001;
$params["templateVars"] = json_encode(["code"=>111111, "min"=>10], true);
ksort($params);
$signStr = "";
foreach ( $params as $key => $value ) {
$signStr = $signStr . $key . "=" . $value . "&";
}
$signStr = substr($signStr, 0, -1);
$verifySignature = base64_encode(hash_hmac("sha1", $signStr, $accessSecret, true));
$params["signature"] = $verifySignature;
$data = http_build_query($params);
$options = array(
"http" => array(
"method" => "POST",
"header" => "Content-Type:application/x-www-form-urlencoded",
"content" => $data
));
$context = stream_context_create($options);
$result = file_get_contents($url, FILE_TEXT, $context);
return $result;
}
echo sendSms();
?>
Copyright ? Yisu Cloud Ltd. All Rights Reserved. 2018 版權所有
廣州億速云計算有限公司 粵ICP備17096448號-1 粵公網安備 44010402001142號 增值電信業務經營許可證編號:B1-20181529