Fix encoding issue
This commit is contained in:
@@ -1,25 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
class Client
|
class Client
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the Rss Feed given a url.
|
* Get the Rss Feed given a url.
|
||||||
*
|
*
|
||||||
* @param mixed $url
|
* @param mixed $url
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get($url) : array
|
public function get($url): array
|
||||||
{
|
{
|
||||||
$response = Http::get($url);
|
$response = Http::get($url);
|
||||||
|
|
||||||
if(!$response->ok())
|
if (!$response->ok()) {
|
||||||
{
|
|
||||||
throw new \Exception("Error getting the rss feed");
|
throw new \Exception("Error getting the rss feed");
|
||||||
}
|
}
|
||||||
|
|
||||||
return json_decode(json_encode(simplexml_load_string($response->body())), true);
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user