Skip to content

Commit

Permalink
Merge pull request #58 from pavelzotikov/fix-curl-transport-json-encode
Browse files Browse the repository at this point in the history
Fix: Use json_encode for event serialization in POST fields
  • Loading branch information
pavelzotikov authored Sep 16, 2024
2 parents e813d70 + 2e1a89f commit 296c740
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @package Hawk
*/
final class Event
final class Event implements \JsonSerializable
{
/**
* @var string
Expand Down Expand Up @@ -53,7 +53,7 @@ public function getEventPayload(): EventPayload
/**
* @return array
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
return [
'token' => $this->integrationToken,
Expand Down
2 changes: 1 addition & 1 deletion src/Transport/CurlTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function send(Event $event)
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $this->url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $event->jsonSerialize());
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($event, JSON_UNESCAPED_UNICODE));
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
Expand Down

0 comments on commit 296c740

Please sign in to comment.