0
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2024-11-23 07:37:35 +00:00
RSS-Bridge_rss-bridge/bridges/TinyLetterBridge.php
Jan Tojnar e07a94d480
Normalize some method calls (#2911)
The methods were called as static even though they were not.
2022-07-09 08:13:07 +02:00

59 lines
1.5 KiB
PHP

<?php
class TinyLetterBridge extends BridgeAbstract
{
const NAME = 'Tiny Letter';
const URI = 'https://tinyletter.com/';
const DESCRIPTION = 'Tiny Letter is a mailing list service';
const MAINTAINER = 'somini';
const PARAMETERS = [
[
'username' => [
'name' => 'User Name',
'required' => true,
'exampleValue' => 'forwards',
]
]
];
public function getName()
{
$username = $this->getInput('username');
if (!is_null($username)) {
return static::NAME . ' | ' . $username;
}
return parent::getName();
}
public function getURI()
{
$username = $this->getInput('username');
if (!is_null($username)) {
return static::URI . urlencode($username);
}
return parent::getURI();
}
public function collectData()
{
$archives = $this->getURI() . '/archive';
$html = getSimpleHTMLDOMCached($archives);
foreach ($html->find('.message-list li') as $element) {
$item = [];
$snippet = $element->find('p.message-snippet', 0);
$link = $element->find('.message-link', 0);
$item['title'] = $link->plaintext;
$item['content'] = $snippet->innertext;
$item['uri'] = $link->href;
$item['timestamp'] = strtotime($element->find('.message-date', 0)->plaintext);
$this->items[] = $item;
}
}
}