From c98f6c265070cfc54a925218c8f63f64e8a34cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C5=A0=C3=ADrek?= Date: Fri, 30 Aug 2019 10:14:30 +0200 Subject: [PATCH] Fix to LinkedIn API v2 --- .gitignore | 1 + src/LinkedIn.php | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5854ebc..a0f0490 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea /build/ composer.lock index.php diff --git a/src/LinkedIn.php b/src/LinkedIn.php index bef60cf..9e35cff 100644 --- a/src/LinkedIn.php +++ b/src/LinkedIn.php @@ -120,7 +120,7 @@ public function api($method, $resource, array $options = []) isset($options['query']) ? $options['query'] : [] ); - $body = isset($options['body']) ? $options['body'] : null; + $body = isset($options['json']) ? json_encode($options['json']) : null; $this->lastResponse = $this->getRequestManager()->sendRequest($method, $url, $options['headers'], $body); //Get the response data format @@ -142,6 +142,9 @@ public function api($method, $resource, array $options = []) */ protected function filterRequestOption(array &$options) { + // Updated by sireko for good working in v2 API + + /* if (isset($options['json'])) { $options['format'] = 'json'; $options['body'] = json_encode($options['json']); @@ -163,6 +166,10 @@ protected function filterRequestOption(array &$options) default: // Do nothing } + */ + + $options['headers']['Content-Type'] = 'application/json'; + $options['headers']['x-li-format'] = 'json'; return $options['format']; }