I am using Laravel 5 with Guzzle and I am attempting to send a message to an android device using Firebase cloud messaging. I have the JSON post message being built in a function with some of the variables passed to the function being used in the JSON message, however, I am getting a client error of HTTP status code 411 when sending. More specifically, Laravel is throwing:
ClientException in Middleware.php line 68: Client error: 411.
I dont see anywhere where FCM requires that this header be set the error is occurring. My guess is that I have constructed the JSON message incorrectly, so here is the function that builds the POST message via GuzzleHttp:
public function ProcessFirebaseNotification($recipientDevID){
$client = new \GuzzleHttp\Client();
$res = $client->request('POST', 'http://ift.tt/1TmHkUo', [
'to' => $recipientDevID,
'notification' => [
'body' => 'Testing FCM',
'title' => 'Testttt',
],
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'key=<-- My FCM Auth KEY -->'
]
]);
return $res->getStatusCode();
}
If I lie and set
'Content-length' => '0'
Then the server throws a 400 Status code because it caught me up in the lie and I have made no progress. I saw other SO posts of people trying to send messages without a body and they get similar errors, but this POST is supposed to have a body.
Please let me know if any further information is needed. Thanks.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire