1
我可以通過PHP發送推送通知,但我想知道的是如何將TTL值設置爲相同?通過PHP在android推送通知中設置TTL值
這是代碼:
<?php
define('API_ACCESS_KEY', 'My API key');
$registrationIds = array($_GET['id']);
$msg = array
(
'message' => 'msg',
'title' => 'title',
'largeIcon' => 'large_icon',
'smallIcon' => 'small_icon');
$fields = array(
'registration_ids' => $registrationIds,
'data' => $msg);
$headers = array(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json');
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send');
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);
curl_close($ch);
echo $result;
?>
無法找到一個方法來做到這一點。任何幫助深表感謝。