I am trying to send fcm notification to a user but, while running this code to deliver the message, it just takes forever, it neither sends nor gives me any response. Using PHP, shared server. Please help.
$msg = array
(
"title" => 'TEST',"body" => 'test',"icon" => '/setup/favicn.png'
);
$fields = array
(
'to' => 'USER_TOKEN',
'data' => $msg
);
$headers = array
(
'Authorization: key=' . 'MY SERVER KEY',
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/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 );
print_r($result);