1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-24 09:02:59 +02:00

fix: various small fixes (#3578)

This commit is contained in:
Dag
2023-07-29 00:14:30 +02:00
committed by GitHub
parent 11ce8b5dcd
commit 701fe3cfed
13 changed files with 87 additions and 39 deletions

View File

@@ -143,18 +143,6 @@ class ReutersBridge extends BridgeAbstract
'wire'
];
/**
* Performs an HTTP request to the Reuters API and returns decoded JSON
* in the form of an associative array
* @param string $feed_uri Full API URL to fetch data
* @return array
*/
private function getJson($uri)
{
$returned_data = getContents($uri);
return json_decode($returned_data, true);
}
/**
* Takes in data from Reuters Wire API and
* creates structured data in the form of a list
@@ -295,8 +283,19 @@ class ReutersBridge extends BridgeAbstract
{
// This will make another request to API to get full detail of article and author's name.
$url = $this->getAPIURL($feed_uri, 'article', $is_article_uid);
$rawData = $this->getJson($url);
try {
$json = getContents($url);
$rawData = Json::decode($json);
} catch (\JsonException $e) {
return [
'content' => '',
'author' => '',
'category' => '',
'images' => '',
'published_at' => ''
];
}
$article_content = '';
$authorlist = '';
$category = [];
@@ -494,7 +493,8 @@ EOD;
{
$endpoint = $this->getSectionEndpoint();
$url = $this->getAPIURL($endpoint, 'section');
$data = $this->getJson($url);
$json = getContents($url);
$data = Json::decode($json);
$stories = [];
$section_name = '';