Skip to content

Commit

Permalink
Merge pull request #26 from FrenchBully/fix/add-guzzle-client-options
Browse files Browse the repository at this point in the history
added Guzzle options to prevent PHP fatal error
  • Loading branch information
AndyGaskell authored Jul 30, 2020
2 parents d188969 + c5b7417 commit 333a546
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/FcmClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,22 @@ public static function create(string $apiToken, string $projectId): FcmClient
*
* @return array
*/
public function send(Request $request): array
public function send(Request $request, array $arguments): array
{
$default = [
'json' => $request->getBody(),
'http_errors' => false
];

$options = is_array($arguments) && isset($arguments) ? $arguments : $default;
// Build guzzle api client.
$client = $this->getGuzzleClient();

// Generate request url.
$url = $request->getUrl();

// Create and send the request.
$response = $client->post($url, [
'json' => $request->getBody()
]);
$response = $client->post($url, $options);

// Decode the response body from json to a plain php array.
$body = json_decode($response->getBody()->getContents(), true);
Expand Down

0 comments on commit 333a546

Please sign in to comment.