28 lines
857 B
PHP
28 lines
857 B
PHP
<?php
|
|
|
|
$filename_data=$argv[1];
|
|
$filename=$argv[2];
|
|
|
|
$dataArray = json_decode(file_get_contents($filename_data), true);
|
|
$regidArrayGCM = json_decode(file_get_contents($filename), true);
|
|
|
|
$headers = array(
|
|
'Authorization: key=AIzaSyAYaXDEapyd-mF9V9LNW1dmuoS-ea9GwWI',
|
|
'Content-Type: application/json');
|
|
$fields = array(
|
|
'registration_ids' => $regidArrayGCM,
|
|
'time_to_live' => 240,
|
|
'priority' => 'high',
|
|
'data' => $dataArray);
|
|
|
|
$context = stream_context_create(array(
|
|
'http' => array(
|
|
'method' => 'POST',
|
|
'header' => $headers,
|
|
'content' => json_encode($fields))));
|
|
|
|
$response = file_get_contents('https://android.googleapis.com/gcm/send', FALSE, $context);
|
|
$filename_rnd = uniqid();
|
|
file_put_contents('/home/francesco/temp/'.$filename_rnd,json_encode($response));
|
|
?>
|