Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
filechange
/
WEBSITE
/
douche
:
sendMultipleFCM.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php if($_SERVER['REQUEST_METHOD']=='POST') { $serverAPIKey ="AAAA-53wG4I:APA91bGyXIRJl0X-AoWeU57KseVze8aiB1rooMerHZmd83vmwX7Q7kFh9-Ugq2S3h_1X_gubzQZjb28YUzgFLRqeQmkJ7_9gukwUnla6_vugNBrp-PHOtx3fHNKrGgUIJ3GFBwBY9EVt7P5rbt5ZS0RJI9qJfpLBHA"; $reg_token ="d7qymBF9f8c:APA91bGhcUXInAjwaGeoorXFD8qr87a_1TWuMg09bqXFWKwz2zMyq5nwGfT9T79IF6LwdTyW3p2F2Bzm-K0QMTznovj2z0dyEyTWc3vOGf9oL38HAPgm_BVjf5gbZpagP4r_xsqCGjRXkavs3jQY_MhONCIrxZnMXw"; $title= $_POST['title']; $message= $_POST['message']; //firebase server url to send the curl request $url = 'https://fcm.googleapis.com/fcm/send'; //building headers for the request $headers = array( 'Authorization: key='. $serverAPIKey, 'Content-Type: application/json' ); //Initializing curl to open a connection $ch = curl_init(); //Setting the curl url curl_setopt($ch, CURLOPT_URL, $url); //setting the method as post curl_setopt($ch, CURLOPT_POST, true); //adding headers curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //disabling ssl support curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $gcmRegIds = array($reg_token); $messagearray = array(); $messagearray['data']['title'] = $title; $messagearray['data']['message'] = $message; //adding the fields in json format $fields = array( 'registration_ids' => $gcmRegIds, 'data' => $messagearray, ); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); //finally executing the curl request $result = curl_exec($ch); curl_close($ch); //and return the result //return $result; } ?> <html> <head> <title>DemoNuts Firebase Cloud Messaging (FCM) Server in PHP</title> <style type="text/css"> #submit { background-color: #4CAF50; border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; } #navigation { position: absolute; /*or fixed*/ right: 0px; margin-right: 270px; } .large { font-size: 14pt; height: 40px; } </style> </head> <body> <div id="navigation" style=" height: 600px ; width : 300px ;"> </div> <h1>Firebase Cloud Messaging (FCM) Server in PHP</h1> <form method="post" action="sendMultipleFCM.php"> <h3>FIREBASE SERVER KEY</h3> <div> <input type="text" class="large" name="serverapi" size="55" placeholder="Enter Your Server KEY"></textarea> </div> <h3>DEVICE TOKEN OR REG.ID</h3> <div> <input class="large" name="token" size="55" placeholder="Enter Device Token or Reg.ID"></textarea> </div> <h3>DEVICE TOKEN OR REG.ID-2</h3> <div> <input class="large" name="token2" size="55" placeholder="Enter Device Token or Reg.ID-2"></textarea> </div> <h3>Message</h3> <div> <textarea rows="6" name="message" cols="63" placeholder="Message to transmit via FCM"></textarea> </div> <h3>Title</h3> <div> <input class="large" name="title" size="55" placeholder="Title to transmit via FCM"></textarea> </div> <h3> Include Image? </h3> <input type="radio" name="isImage" id="no" value="Yes" checked/>Yes <input type="radio" name="isImage" id="no" value="No">No<br> <input type="submit" name="submit" value="Go Go Go...!" id="submit" /><br> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html>