Added wp api call error handle
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user