27 lines
617 B
PHP
27 lines
617 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
use GuzzleHttp\Client as HTTPClient;
|
|
|
|
class WpContentsClient
|
|
{
|
|
|
|
public static function serviceGetBlogItems($apiEndpointsUrl)
|
|
{
|
|
$client = new HTTPClient();
|
|
try {
|
|
$response = $client->request(
|
|
'GET',
|
|
"{$apiEndpointsUrl}/wordpress-data",
|
|
['connect_timeout' => 2, 'timeout' => 3, 'debug' => false]
|
|
);
|
|
} catch (Exception $e) {
|
|
// echo "\n".$e->getMessage()."\n";
|
|
$response= []; // empty array
|
|
}
|
|
return json_decode($response->getBody());
|
|
}
|
|
}
|
|
|
|
|