Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 一些用户在夜间收到来自我的android应用程序的通知_Php_Android - Fatal编程技术网

Php 一些用户在夜间收到来自我的android应用程序的通知

Php 一些用户在夜间收到来自我的android应用程序的通知,php,android,Php,Android,一些用户在夜间收到来自我的android应用程序的通知 他们抱怨说,他们在深夜收到通知,并且整天不间断地使用互联网数据 下面给出的代码用于向Google云消息发送请求,以便在每次迭代中向1000个用户发送推送通知 请说明问题出在哪里,以及是什么 提前谢谢大家 <? set_time_limit ( 100 ); if (isset($_POST["submit"]) && isset($_POST["message"])) { $regId = ""; $func

一些用户在夜间收到来自我的android应用程序的通知 他们抱怨说,他们在深夜收到通知,并且整天不间断地使用互联网数据

下面给出的代码用于向Google云消息发送请求,以便在每次迭代中向1000个用户发送推送通知

请说明问题出在哪里,以及是什么

提前谢谢大家

<?

set_time_limit ( 100 ); 
if (isset($_POST["submit"]) && isset($_POST["message"])) 
{ $regId = "";

$func = new DB_Functions();
$gcm = new GCM();
$message = $_POST["message"];
$message = array("newmsg" => $message);
$send_users = 0;
$limit = "";
$users = $func->getAllUsers($limit);
$no_of_users = mysql_num_rows($users);

$count = $no_of_users/1000;
for($i = 0; $i < $count; $i++)
{
    $registatoin_ids = array();
    $from = round($i,0)*1000;
    $limit = " limit ".$from.",1000";
    //$limit = " limit 0,2";
    $regids = $func->getAllUsers($limit);
    while($rs = mysql_fetch_array($regids))
    {
            array_push($registatoin_ids, $rs['gcm_`enter code here`regid']);
    }
    $result = $gcm->send_notification($registatoin_ids, $message);
}

}

public function send_notification($registatoin_ids, $message) 
{
// include config      
include_once './config.php';

// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';

$fields = array(
    'registration_ids' => $registatoin_ids,
    'data' => $message,
);

$headers = array(
    'Authorization: key=' . GOOGLE_API_KEY,
    'Content-Type: application/json'
);
// Open connection
$ch = curl_init();

// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));

// Execute post
$result = curl_exec($ch);
if ($result === FALSE) {
    die('Curl failed: ' . curl_error($ch));
}

// Close connection
curl_close($ch);
return $result;
}
?>

通知可以在任何时候发出,这取决于数据的可用性,但是用户说他们正在持续使用互联网数据,那么预期的senario是什么?那么如果有12小时的时差呢?我在浏览器界面中使用php代码发送通知发送请求的代码