bridges: Don't kill scripts with die()
Bridges should generally utilize the API functions instead of killing the script. Find more information on the Wiki. - returnServerError https://github.com/RSS-Bridge/rss-bridge/wiki/The-returnServerError-function - returnClientError https://github.com/RSS-Bridge/rss-bridge/wiki/The-returnClientError-function - returnError https://github.com/RSS-Bridge/rss-bridge/wiki/The-returnError-function
This commit is contained in:
parent
35bd706391
commit
3d231a417f
4 changed files with 16 additions and 14 deletions
|
@ -91,7 +91,8 @@ class Arte7Bridge extends BridgeAbstract {
|
||||||
'Authorization: Bearer ' . self::API_TOKEN
|
'Authorization: Bearer ' . self::API_TOKEN
|
||||||
);
|
);
|
||||||
|
|
||||||
$input = getContents($url, $header) or die('Could not request ARTE.');
|
$input = getContents($url, $header)
|
||||||
|
or returnServerError('Could not request ARTE.');
|
||||||
$input_json = json_decode($input, true);
|
$input_json = json_decode($input, true);
|
||||||
|
|
||||||
foreach($input_json['videos'] as $element) {
|
foreach($input_json['videos'] as $element) {
|
||||||
|
|
|
@ -72,15 +72,15 @@ class FB2Bridge extends BridgeAbstract {
|
||||||
$pageInfo = $this->getPageInfos($page, $cookies);
|
$pageInfo = $this->getPageInfos($page, $cookies);
|
||||||
|
|
||||||
if($pageInfo['userId'] === null) {
|
if($pageInfo['userId'] === null) {
|
||||||
echo <<<EOD
|
returnClientError(<<<EOD
|
||||||
Unable to get the page id. You should consider getting the ID by hand, then importing it into FB2Bridge
|
Unable to get the page id. You should consider getting the ID by hand, then importing it into FB2Bridge
|
||||||
EOD;
|
EOD
|
||||||
die();
|
);
|
||||||
} elseif($pageInfo['userId'] == -1) {
|
} elseif($pageInfo['userId'] == -1) {
|
||||||
echo <<<EOD
|
returnClientError(<<<EOD
|
||||||
This page is not accessible without being logged in.
|
This page is not accessible without being logged in.
|
||||||
EOD;
|
EOD
|
||||||
die();
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ EOD;
|
||||||
foreach($html->find('article') as $content) {
|
foreach($html->find('article') as $content) {
|
||||||
|
|
||||||
$item = array();
|
$item = array();
|
||||||
//echo $content; die();
|
|
||||||
preg_match('/publish_time\\\":([0-9]+),/', $content->getAttribute('data-store', 0), $match);
|
preg_match('/publish_time\\\":([0-9]+),/', $content->getAttribute('data-store', 0), $match);
|
||||||
if(isset($match[1]))
|
if(isset($match[1]))
|
||||||
$timestamp = $match[1];
|
$timestamp = $match[1];
|
||||||
|
|
|
@ -8,8 +8,8 @@ class GOGBridge extends BridgeAbstract {
|
||||||
|
|
||||||
public function collectData() {
|
public function collectData() {
|
||||||
|
|
||||||
$values = getContents('https://www.gog.com/games/ajax/filtered?limit=25&sort=new') or
|
$values = getContents('https://www.gog.com/games/ajax/filtered?limit=25&sort=new')
|
||||||
die('Unable to get the news pages from GOG !');
|
or returnServerError('Unable to get the news pages from GOG !');
|
||||||
$decodedValues = json_decode($values);
|
$decodedValues = json_decode($values);
|
||||||
|
|
||||||
$limit = 0;
|
$limit = 0;
|
||||||
|
@ -38,8 +38,8 @@ class GOGBridge extends BridgeAbstract {
|
||||||
|
|
||||||
private function buildGameContentPage($game) {
|
private function buildGameContentPage($game) {
|
||||||
|
|
||||||
$gameDescriptionText = getContents('https://api.gog.com/products/' . $game->id . '?expand=description') or
|
$gameDescriptionText = getContents('https://api.gog.com/products/' . $game->id . '?expand=description')
|
||||||
die('Unable to get game description from GOG !');
|
or returnServerError('Unable to get game description from GOG !');
|
||||||
|
|
||||||
$gameDescriptionValue = json_decode($gameDescriptionText);
|
$gameDescriptionValue = json_decode($gameDescriptionText);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ class Rue89Bridge extends BridgeAbstract {
|
||||||
public function collectData() {
|
public function collectData() {
|
||||||
|
|
||||||
$jsonArticles = getContents('https://appdata.nouvelobs.com/rue89/feed.json')
|
$jsonArticles = getContents('https://appdata.nouvelobs.com/rue89/feed.json')
|
||||||
or die('Unable to query Rue89 !');
|
or returnServerError('Unable to query Rue89 !');
|
||||||
$articles = json_decode($jsonArticles)->items;
|
$articles = json_decode($jsonArticles)->items;
|
||||||
foreach($articles as $article) {
|
foreach($articles as $article) {
|
||||||
$this->items[] = $this->getArticle($article);
|
$this->items[] = $this->getArticle($article);
|
||||||
|
@ -19,7 +19,8 @@ class Rue89Bridge extends BridgeAbstract {
|
||||||
|
|
||||||
private function getArticle($articleInfo) {
|
private function getArticle($articleInfo) {
|
||||||
|
|
||||||
$articleJson = getContents($articleInfo->json_url) or die('Unable to get article !');
|
$articleJson = getContents($articleInfo->json_url)
|
||||||
|
or returnServerError('Unable to get article !');
|
||||||
$article = json_decode($articleJson);
|
$article = json_decode($articleJson);
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['title'] = $article->title;
|
$item['title'] = $article->title;
|
||||||
|
|
Loading…
Reference in a new issue