在GET上添加到PHP变量

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"?

you are passing data index in array more than once, change:

$fields = array(
    'registration_ids'  => array( $reg_id ),
    'data'              => array( "message" => $message ),
    'data'              => array( "val1" => $val1 ),
);

to

$fields = array(
    'registration_ids'  => array( $reg_id ),
    'data'              => array( "message" => $message, "val1" => $val1 )
);

and you declared $val variable and are trying to use $val1, change to:

$val = filter_input (INPUT_GET, 'val', FILTER_SANITIZE_EMAIL);
send_gcm_notify($reg_id, $msg, $val);