HTML
<?php
$API_KEY="AAAAoyz8W_Q:APA91bFIJxTqoBnQo218QIIXi7uCmHFRP604RTC......";
$url = "https://fcm.googleapis.com/fcm/send";
$headers = array(
'Authorization:key='.$API_KEY,
'Content-Type:application/json'
);
$token="2tJfPjKZQ6UTVG....";
$notify=array("message"=>
array('token' =>$token,
'notification'=>array('title'=>"Title",
'body'=>"Body")));
$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_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($notify));
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}else{
echo $ch;
}
curl_close ( $ch );
?>
JS
<input id="inputText" type="text" />
打开“我的页面”时,我想通过重点关注document.getElementById('inputText').focus();
标签来显示移动键盘。