From 96e2507f2802f0bf83ea303bb017919844ce67b6 Mon Sep 17 00:00:00 2001 From: Karel Wintersky Date: Thu, 4 Aug 2022 04:38:23 +0300 Subject: [PATCH] 1.0.4 * [+] Release * [+] `getPageFullExport()` can return array or stdClass --- interfaces/LongreadsInterface.php | 5 +++-- sources/Longreads.php | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/interfaces/LongreadsInterface.php b/interfaces/LongreadsInterface.php index 775ed31..4255213 100644 --- a/interfaces/LongreadsInterface.php +++ b/interfaces/LongreadsInterface.php @@ -125,9 +125,10 @@ public function fetchPagesList(): array; * Возвращает Json-decoded информацию о лонгриде * * @param $id - * @return stdClass + * @param null $associative (null|true) + * @return stdClass|array */ - public function getPageFullExport($id):stdClass; + public function getPageFullExport($id, $associative = null); } # -eof- diff --git a/sources/Longreads.php b/sources/Longreads.php index 832afbd..c7b4c3c 100644 --- a/sources/Longreads.php +++ b/sources/Longreads.php @@ -622,7 +622,7 @@ public function fetchPagesList():array return $pages_list; } - public function getPageFullExport($id):stdClass + public function getPageFullExport($id, $associative = null) { $http_request_query = [ 'publickey' => $this->api_options['public_key'], @@ -641,7 +641,7 @@ public function getPageFullExport($id):stdClass throw new RuntimeException( "[getPageFullExport] ERROR: Не удалось получить данные с Tilda API" ); } - $response = json_decode($response); + $response = json_decode($response, $associative); if (false === $response) { throw new RuntimeException( "[getPageFullExport] ERROR: Не удалось json-декодировать данные с Tilda API" ); @@ -652,7 +652,7 @@ public function getPageFullExport($id):stdClass } catch (RuntimeException $e) { $this->logger->debug($e->getMessage(), [ $e->getCode(), $url ]); - return new stdClass(); + return $associative ? [] : new stdClass(); } }