diff --git a/app/Services/WpContentsClient.php b/app/Services/WpContentsClient.php index 82c3f73..0e2c71a 100644 --- a/app/Services/WpContentsClient.php +++ b/app/Services/WpContentsClient.php @@ -5,13 +5,20 @@ use GuzzleHttp\Client as HTTPClient; class WpContentsClient { + public static function serviceGetBlogItems($apiEndpointsUrl) { $client = new HTTPClient(); - $response = $client->request( - 'GET', - "{$apiEndpointsUrl}/wordpress-data" - ); + try { + $response = $client->request( + 'GET', + "{$apiEndpointsUrl}/wordpress-data", + ['connect_timeout' => 2, 'timeout' => 3, 'debug' => true] + ); + } catch (Exception $e) { + // echo "\n".$e->getMessage()."\n"; + $response= []; // empty array + } return json_decode($response->getBody()); } }