Tryag File Manager
Home
||
Turbo Force
||
B-F Config_Cpanel
Current Path :
/
home
/
egg.eemo.co.kr
/
public_html
/
super5
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/egg.eemo.co.kr/public_html/super5/test_fcm_push.php
<? session_cache_limiter('no-cache, must-revalidate'); session_start(); header("Pragma: no-cache"); header("Cache-Control: no-cache,must-revalidate"); header("Content-Type: text/html; charset=utf-8"); include_once("dbconn.php"); include_once("lib.php"); foreach($_GET as $key => $value) { ${$key}=mysql_real_escape_string(trim($value)); } foreach($_POST as $key => $value) { ${$key}=mysql_real_escape_string(trim($value)); } function send_notification($tokens, $message) { $url = 'https://fcm.googleapis.com/fcm/send'; $fields = array( 'registration_ids' => $tokens, 'data' => $message ); $key = "AIzaSyCSyMt_dslz98MD0CzbmiiwG4eyGv-E7pc"; $headers = array( 'Authorization:key =' . $key, '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_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $response = curl_exec($ch); curl_close($ch); $json=json_decode($response,true); //NotRegistered = 앱삭제 if($json["success"]) { } echo $response; } $tokens = array(); $tokens[0] = "eWf_WuoZ4MI:APA91bGf_Gj9b6fW1jDhhM3v_-Jaxmz-3A_bWi5UWIs8DkI1PvN07Gvn27XMITzgYsWaIYpE3KBJ32bYVjwuVhSA0z0AnaZajuyCDET9WbId3s36tyln0dLZHHkFuI72eTWNpbthrK4c"; $myMessage = "고객님의 농가에<br>A동 5번 온도센서에<br>기준치 5도씨 오버"; $tts = "고객님의 농가에 A동 5번 온도센서에 기준치 5도씨 오버"; if ($myMessage == ""){ $myMessage = "Newly registered."; } $arr_pmode=array( "1"=>"notice", "2"=>"warning", ); $message = array("message" => $myMessage,"title" => "경고 발생","mode" => $arr_pmode[2],"sound" => "1","tts" => $tts, "istts" => "1"); send_notification($tokens, $message); ?>