发送POST REQUEST Firebase云消息传递

EDITED. Solved at the end of the post.

I´m trying to update GCM to FCM and everything works perfect but the connection with the Firebase API.

In GCM I sent had this code from my PHP script:

define( 'API_ACCESS_KEY', 'myapikeynumber');
$registrationIds = array($registrationID);
$msg = array
    (
    'message'         => $message,
    'title'           => 'You have new notification(s)',
    'subtitle'        => 'Please click to view your notification(s)',
    'user_id'         => $user_id,
    'user_type'       => $user_type,
    'notification_id' => $notification_id
    );
$fields = array
    (
    'registration_ids'  => $registrationIds,
    'data'              => $msg,
    'time_to_live'      => 3
    );
$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;

But now don´t know which fields or values I need send to the https://fcm.googleapis.com/fcm/send.

Any help?


SOLUTION

The problem was here:

$registrationIds = array($registrationID);
$fields = array
    (
    'registration_ids'  => $registrationIds,
    'data'              => $msg,
    'time_to_live'      => 3
    );

Because $registrationsIds had not JSON structure.

So the code is nearly the same, just change that and the URL of the API to https://fcm.googleapis.com/fcm/send.