Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
[BinanceBridge] Remove announcements because of Cloudflare issue (RSS…
Browse files Browse the repository at this point in the history
  • Loading branch information
thefranke authored and Kwbmm committed Jun 17, 2022
1 parent ba74435 commit 7298ca9
Showing 1 changed file with 6 additions and 62 deletions.
68 changes: 6 additions & 62 deletions bridges/BinanceBridge.php
Original file line number Diff line number Diff line change
@@ -1,41 +1,18 @@
<?php
class BinanceBridge extends BridgeAbstract {
const NAME = 'Binance';
const URI = 'https://www.binance.com';
const DESCRIPTION = 'Subscribe to the Binance blog or the Binance Zendesk announcements.';
const NAME = 'Binance Blog';
const URI = 'https://www.binance.com/en/blog';
const DESCRIPTION = 'Subscribe to the Binance blog.';
const MAINTAINER = 'thefranke';
const CACHE_TIMEOUT = 3600; // 1h

const PARAMETERS = array( array(
'category' => array(
'name' => 'category',
'type' => 'list',
'exampleValue' => 'Blog',
'title' => 'Select a category',
'values' => array(
'Blog' => 'Blog',
'Announcements' => 'Announcements'
)
)
));

public function getIcon() {
return 'https://bin.bnbstatic.com/static/images/common/favicon.ico';
}

public function getName() {
return self::NAME . ' ' . $this->getInput('category');
}

public function getURI() {
if ($this->getInput('category') == 'Blog')
return self::URI . '/en/blog';
else
return 'https://binance.zendesk.com/hc/en-us/categories/115000056351-Announcements';
}

protected function collectBlogData() {
$html = getSimpleHTMLDOM($this->getURI());
public function collectData() {
$html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not fetch Binance blog data.');

$appData = $html->find('script[id="__APP_DATA"]');
$appDataJson = json_decode($appData[0]->innertext);
Expand All @@ -61,37 +38,4 @@ protected function collectBlogData() {
break;
}
}

protected function collectAnnouncementData() {
$html = getSimpleHTMLDOM($this->getURI());

foreach($html->find('a.article-list-link') as $a) {
$title = $a->innertext;
$uri = 'https://binance.zendesk.com' . $a->href;

$full = getSimpleHTMLDOMCached($uri);
$content = $full->find('div.article-body', 0);
$date = $full->find('time', 0)->getAttribute('datetime');

$item = array();

$item['title'] = $title;
$item['uri'] = $uri;
$item['timestamp'] = strtotime($date);
$item['author'] = 'Binance';
$item['content'] = $content;

$this->items[] = $item;

if (count($this->items) >= 10)
break;
}
}

public function collectData() {
if ($this->getInput('category') == 'Blog')
$this->collectBlogData();
else
$this->collectAnnouncementData();
}
}

0 comments on commit 7298ca9

Please sign in to comment.