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' => '0', // type为0表示即时消息
'sign' => $sign,
'time' => $time,
'from' => 'YourID', // 开发者ID
'to' => 'YourID', // 接收者的创见用户ID
'template' => 'T1607159430540', // 模板编号
'data' => Array(
'${name}' => 'NAME',
'${code}' => '189546'
) // 模板变量,这里用的数组
);
$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;
}