Through the obsolete HTTP server protocol ( https://fcm.googleapis.com/fcm/send ) everything works.

But through the new API, I upload to authorization. 1. How to get a token in the php script?

<?php $registrationIds = 'myAppID'; $data = array( "key" => "value" ); $notification = array( "title" => "Title" , "body" => "Notification text" ); $message = array( "data" => $data, "notification" => $notification, "topic" => "news" ); $body_msg = array( "validate_only" => false, "message" => $message ); $fields = json_encode( $body_msg ); $token = ''; //вот тут вопрос $headers = array ( 'Authorization: Bearer ' . $token, 'Content-Type: application/json' ); $ch = curl_init(); curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/v1/projects/myproject-12345/messages: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, $fields ); $result = curl_exec($ch ); curl_close( $ch ); echo $result; ?> 
  1. How to send messages from the Android application?

Poke my nose at examples, instructions. In general, point in the right direction.

    0