QQ消息发送接口的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' => '2', // type为2表示QQ消息
'sign' => $sign,
'time' => $time,
'from' => 'YourID', // 开发者ID
'to' => 'YourQQ', // 接收者的QQ号
'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;
}
  • 真诚Empressment
  • 高效Efficiency
  • 进取Enterprise
WEIXIN
PHONE
CALL
QQ
TOP
X