Level 16
Provide a code that explains how you use dynamic data.
You can do something like
$dataString = json_encode($dataItem);
...
"data" : $dataItem ,
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I am using Firebase notification below is my CURL code I am calling this function on order status change.
$order_id = 123;
$order_status = "pending";
if($order->save()){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://fcm.googleapis.com/fcm/send',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"to" : "e7Oeb3OAXUmMry4gP0LxFP:APA91bHKwTT2TpWxAJY17lxtvIjg_eYOlOLgkVPnrgAf9cmDsiFV6-Kz3BTl1DipDDJGhA8sFbnaUaGeajIunY6hsCjsu-q8xpssU8z8VgXnhlLOnpZPVmZ-SyalO-h4M4RCKcDhjQS7",
"data" : {
"title":"Android",
"order_id" :1,
"order_status" :"pending",
},
}',
CURLOPT_HTTPHEADER => array(
'Authorization: key=AAAAfexbmoo:APA91bE5VzPqQqF_U1CIgYTV2mk_q-SmW6veR4w1pF2IYH6Jw1WoFqsQ8VN7mQcJOqyaAinByslgyvSy8JDABeXCuyn1rNegjk8MTwEFck97uaf1AD9aBFPQdsNVkbFExdKeON6VaYyp',
'Content-Type: application/json'
),
));
Things are working fine on static data. If I use dynamic values in data collection then notifications are not working
Please help me to fix this :)
Please or to participate in this conversation.