- PHP 100%
| .gitignore | first commit | |
| class.Bsky.php | stop card generator if doc is not loadable by DOMDocument::loadHTMLFile | |
| config.sample.php | new config option do-remember; solution for #12 | |
| post | changed phps short open tag to long open tag | |
| README.md | new config option: do-post ( #12 ) | |
| rss2bsky.php | fix for new config option do-remember; solution for #12 | |
| test | improved image detection for card generation; possible solution for #16 | |
rss2bsky
Post items of multiple RSS-Feeds to Bluesky. Also contains a simple script to post a single skeet ("sky tweet") to Bluesky.
Requirements
- PHP with SQLite3, CURL, SimpleXML, GD and Multibyte String support
- SimplePie
- Bluesky-Account
on Ubuntu and similar oses you could install the local requirements with:
apt install php-sqlite3 php-curl php-xml php-mbstring php-gd libphp-simplepie
Installation
- clone this repository
cd $repository-directorymkdir libmkdir cachechown www-data.www-data cache(assuming your webserver runs as www-data; adjust if necessary)- copy or link
SimplePie.compiled.phptolib/SimplePie.compiled.php(/usr/share/php/simplepie/SimplePie.compiled.phpor see Where's simplepie.inc?)
Configuration
- copy config.sample.php to
config.php - adjust config.php:
// first feed
$config['feeds'][] = [
'feed-url' => 'https://your.websi.te/feed.rss', // url of a rss feed
'feed-item-maxage' => 60*60*24*2, // maximum age in seconds of feed items that should be posted to bsky
'feed-cache-duration' => 60*60, // time in seconds after that simplepie reloads the feed
'bluesky-username' => 'you.bsky.social', // your bsky username
'bluesky-password' => 'abcd-efgh-ijkl-mnop', // app-password to your bsky account (see https://bsky.app/settings/app-passwords)
'bluesky-language' => 'de-DE', // if not set language is automatically read from the feed
'bluesky-post-prefix' => 'New! ', // fixed text prepended before every posted item
'bluesky-post-suffix' => ' #hashtag', // fixed text appended after every posted item
'do-post' => true, // posting to bluesky is enabled (true) or disabled (false) for this feed. Optional setting, default is true
];
// second feed
$config['feeds'][] = [ // repeat $config['feeds'][] for every feed you want to post to bsky
... // you may use different bsky accounts, cache-durations etc.
]; // all configuration options are needed for every feed (no default settings)
// global settings
$config['cache-dir'] = '/path/to/cache'; // absolute path* to a directory where simplepie stores it's feedcache
$config['sqlite-filename'] = $config['cache-dir'].'/rss2bsky.db'; // absolute path* to the filename for a sqlite3 database, where rss2bsky stores status information about feed items
$config['do-post'] = true; // posting to bluesky is globally enabled (true) or disabled (false) for all feeds. Optional setting, default is true
* in some configurations a relative path to $config['cache-dir'] works, but I found it best to provide an absolute path, just to be sure
Run
rss2bsky
post all new items of the configured rss feeds:
/usr/bin/php rss2bsky.php
preferably this should run periodically via cron:
0 * * * * /usr/bin/php /opt/rss2bsky/rss2bsky.php > /dev/null
once per hour is sufficient in most cases. If you need faster updates remember to change feed-cache-duration accordingly
post
post a single skeet:
./post "text of your skeet in quotes"
License
This repository is free under the requirements of CC-BY-4.0 (Creative Commons Namensnennung 4.0 International Public License)