From a01d57eb158ed577d1b92130c279c87173d89dc5 Mon Sep 17 00:00:00 2001 From: Mojtaba Date: Wed, 7 Nov 2018 10:51:07 +0330 Subject: [PATCH] Avoid getting the "Syntax error" from json_decode Avoid getting the "Syntax error" from json_decode when when LinkedIn API returns an empty response. --- src/Client.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Client.php b/src/Client.php index afdd9b3..c2ad242 100644 --- a/src/Client.php +++ b/src/Client.php @@ -308,10 +308,13 @@ public function getAccessToken($code = '') */ public static function responseToArray($response) { - return \GuzzleHttp\json_decode( - $response->getBody()->getContents(), - true - ); + if ($contents = $response->getBody()->getContents()) { + return \GuzzleHttp\json_decode( + $contents, + true + ); + } + return array(); } /**