This PHP file that sends a push GCM
I tried to add another variable to file "val" And probably made a mistake that the file is not working right now.
<?php
define("GOOGLE_API_KEY", "AIzaSyBNSwEoWlFQAW9AoHvlMcf2eXx2NchURaE");
define("GOOGLE_GCM_URL", "https://android.googleapis.com/gcm/send");
function send_gcm_notify($reg_id, $message, $val1) {
$fields = array(
'registration_ids' => array( $reg_id ),
'data' => array( "message" => $message ),
'data' => array( "val1" => $val1 ),
);
$headers = array(
'Authorization: key=' . GOOGLE_API_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, GOOGLE_GCM_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($fields));
$result = curl_exec($ch);
if ($result === FALSE) {
die('Problem occurred: ' . curl_error($ch));
}
curl_close($ch);
echo $result;
}
$reg_id = file_get_contents("TXTreg.txt");
$msg = filter_input (INPUT_GET, 'msg', FILTER_SANITIZE_EMAIL);
$val = filter_input (INPUT_GET, 'val', FILTER_SANITIZE_EMAIL);
send_gcm_notify($reg_id, $msg, $val1);
What should be done to the file will work with the variable "val"?