我正在使用后端通过laravel通过laravel向android发送通知,但出现错误“将.json附加到您的请求URI以使用REST API”。使用Postman我正在运行此api
This is function which is used to get notification in json in my controller
public function sendNotification(Request $req)
{
$fcmUrl = 'https://playout-52d1f.firebaseio.com';
$token=$req->input('token');
$title=$req->input('title');
$notification = [
'title' => $title,
'sound' => true,
];
$extraNotificationData = ["message" => $notification,"moredata" =>'dd'];
$fcmNotification = [
//'registration_ids' => $tokenList, //multple token array
'to' => $token, //single token
'notification' => $notification,
'data' => $extraNotificationData
];
$headers = [
'Authorization: key=AIzaSyDF4_rqij_Bt4zC3GNEVbNFvwX1HHxy5Mo',
'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);
dd($result );
}