$fcmUrl = 'https://fcm.googleapis.com/fcm/send';
$apikey = 'xxx';
$fcmNotification = [
'priority'=>'high',
"content_available"=> true,
"mutable_content"=> true,
'to' => '/topics/<your_topic_name>',
"notification" => [
'subText' => "Sub title",
'title' => "Title",
'body' => "Body text"
'sound' => 'default',
'badge' => '0'
],
'data' => [
'type' => 'text/image',
'attachment-url' => "https://example.com/secure-image-url", //must be a secure url (https)
]
];
$headers = ['Authorization: key=' . $apikey, 'Content-Type: application/json'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$fcmUrl);
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($fcmNotification));
$result = curl_exec($ch);
curl_close($ch);