27 lines
575 B
PHP
27 lines
575 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
class Client
|
|
{
|
|
/**
|
|
* Get the Rss Feed given a url.
|
|
*
|
|
* @param mixed $url
|
|
* @return array
|
|
*/
|
|
public function get($url): array
|
|
{
|
|
$response = Http::get($url);
|
|
|
|
if (!$response->ok()) {
|
|
throw new \Exception("Error getting the rss feed");
|
|
}
|
|
|
|
// Decode Html entity before passing the data to xml loader to decode
|
|
return json_decode(json_encode(simplexml_load_string(html_entity_decode($response->body()))), true);
|
|
}
|
|
}
|