Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EpicgamesBridge] New bridge #1709

Merged
merged 4 commits into from
Aug 20, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions bridges/EpicgamesBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
class EpicgamesBridge extends BridgeAbstract {

const NAME = 'Epicgames News';
const MAINTAINER = 'otakuf';
const URI = 'https://www.epicgames.com';
const DESCRIPTION = 'Returns the latest posts from epicgames.com';
const CACHE_TIMEOUT = 3600; // 60min

const PARAMETERS = array( array(
'postcount' => array(
'name' => 'Limit',
'type' => 'list',
'values' => array(
'5' => 5,
'10' => 10,
'15' => 15,
'20' => 20,
'25' => 25,
),
'title' => 'Maximum number of items to return',
'defaultValue' => 10,
),
'language' => array(
'name' => 'Language',
'type' => 'list',
'values' => array(
'Eng' => 'en',
'Rus' => 'ru',
),
'title' => 'Language of blog posts',
'defaultValue' => 'en',
),
));

public function collectData() {
// Example: https://store-content.ak.epicgames.com/api/ru/content/blog?limit=25
$api = 'https://store-content.ak.epicgames.com/api/';
$url = $api . $this->getInput('language') . '/content/blog?limit=' . $this->getInput('postcount');

$data = getContents($url)
or returnServerError('Unable to get the news pages from epicgames !');
$decodedData = json_decode($data);

foreach($decodedData as $key => $value) {
$item = array();
$item['uri'] = self::URI . $value->url;
$item['title'] = $value->title;
$item['timestamp'] = $value->date;
$item['author'] = $value->author;

$content = $value->content;
$content = str_replace('href="/', 'href="' . self::URI . '/', $content);
$item['content'] = $content;

$item['enclosures'][] = $value->image;
$item['uid'] = $value->_id;
$item['id'] = $value->_id;
$this->items[] = $item;
}
}
}