Android
- 1 ответ
- 0 вопросов
1
Вклад в тег
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, htmlspecialchars_decode('https://fcm.googleapis.com/fcm/send'));
curl_setopt($ch, CURLOPT_POST, true);
$headers = [
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 2);
$fields = [
'to' => 'userAgentToken',
'notification' => [
'body' => 'Some body text',
'title' => 'Some title text'
]];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
curl_exec($ch);
curl_close($ch);