可以用PHP,卷曲发短信
function sendGCM($message, $id) {
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array (
'registration_ids' => array (
$id
),
'data' => array (
"message" => $message
)
);
$fields = json_encode ($fields);
$headers = array (
'Authorization: key=' . "YOUR_KEY_HERE",
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields);
$result = curl_exec ($ch);
echo $result;
curl_close ($ch);
}
?>
$消息是你的消息发送到设备
$ id是器械注册令牌
YOUR_KEY_HERE是你的服务器API密钥(或传统服务器API密钥)
即使您拥有数千名参与者或数百万人,您也不会遇到任何问题,而且您不必执行任何其他操作,如执行xmpp或其他任何操作r协议firebase和谷歌管理这一点。 –
不会有任何延迟。有两种协议可以使用:HTTP或XMPP –