短信推送接口的PHP开发实例
header('Content-Type: text/html; charset=UTF-8');
date_default_timezone_set("PRC");
$time = date('YmdGis'); // 时间为纯数字
$API_Secret = '82ldi87efv'; // 开发者密匙
$sign = md5($API_Secret . $time); // 通过MD5加密生成签名
$arySend = Array(
'type' => '1', // type为1表示发送短信
'sign' => $sign,
'time' => $time,
'from' => 'YourID', // 开发者ID
'to' => '13300009999', // 接收者手机号
'template' => 'T1607159183124', // 模板编号
'data' => Array(
'${code}' => '189546',
'${product}' => 'PRODUCT'
) // 模板变量,这里用的数组
);
$result = sms_send($arySend); // 调用发送函数
exit($result);
function sms_send($Array_Send)
{
$data = json_encode($Array_Send);
$server = 'http://transidc.com/?mod=message&type=api';
$timeout = 5;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $server);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$result = @curl_exec($ch);
curl_close($ch);
return $result;
}
  • 真诚Empressment
  • 高效Efficiency
  • 进取Enterprise
WEIXIN
PHONE
CALL
QQ
TOP
X