[EDIT] FILE: test.php
f<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); echo 'dsd'; //API URL of FCM $url = 'https://fcm.googleapis.com/fcm/send'; /*api_key available in: Firebase Console -> Project Settings -> CLOUD MESSAGING -> Server key*/ $api_key = 'AAAAmvXY1N8:APA91bHZWMGHRadYCgzE354MdYf7nfqmMyfxO4XvjfMSYV6GNZ4m06fjMnwJdDQQmGCEvidU5HSU8Eb8jY3V71SJW1os-LTT0nrYZWkpNUNuHaBA9iv9BIvTz9n6Db9hf7a_GMv7Ud-i'; $fields = array ( 'registration_ids' => array ( "rg" ), 'data' => array ( "message" => 'dfgdfg' ) ); $api_key = 'AAAAn-F4NX4:APA91bGo1j7rqDpc1FtozZl7-2K4CdBGuZ5sIWX1uWisPCu-zRl_ynaYkslQxR6X7xjZygeAHIv_O-qInCZ5z_ZKrQfjrOJCVeAH8fg-AF_esgO6oemNPrdY_SqnzXerCmQcwxTE3TvK'; //header includes Content type and api key $headers = array( 'Content-Type:application/json', 'Authorization:key='.$api_key ); $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_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('FCM Send Error: ' . curl_error($ch)); } curl_close($ch); return $result;
SAVE
CANCEL