0
下面是我用於執行Push to Chrome用戶的代碼,現在我想通知給Firefox用戶,並且我知道它現在將通過url目標「https://updates.push.services.mozilla.com/push 「如何執行Curl向Firefox中的用戶發送通知
但我不知道我要做什麼。
我在Chrome上運行的代碼如下。
<?php
include('header.php');
define('API_ACCESS_KEY', '[API-KEY comes here]');
$sql="SELECT * FROM user_data";
$result = mysqli_query($conn, $sql) or die ('Error'.mysqli_error($conn));
$registrationIds=array();
while($row=mysqli_fetch_assoc($result)){
$registrationIds[] = $row['allow'];
}
$ids=json_encode($registrationIds);
$fields = array
(
'registration_ids' => $registrationIds
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send');
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($fields));
$result = curl_exec($ch);
curl_close($ch);
echo $result;
?>