forked from RSS-Bridge/rss-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TinyLetter: New Bridge (RSS-Bridge#1469)
* TinyLetter: New Bridge
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?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 = array( | ||
array( | ||
'username' => array( | ||
'name' => 'User Name', | ||
'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 = self::getURI() . '/archive'; | ||
$html = getSimpleHTMLDOMCached($archives) | ||
or returnServerError('Could not load content'); | ||
|
||
foreach($html->find('.message-list li') as $element) { | ||
$item = array(); | ||
|
||
$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; | ||
} | ||
|
||
} | ||
} |