3
6
Fork
You've already forked rss2bsky
5
Post items of a RSS-Feed to Bluesky. Also contains a simple script to post a single skeet to Bluesky. Written in PHP
  • PHP 100%
2024年01月04日 22:33:45 +01:00
.gitignore first commit 2023年10月08日 01:04:25 +02:00
class.Bsky.php stop card generator if doc is not loadable by DOMDocument::loadHTMLFile 2024年01月04日 22:33:45 +01:00
config.sample.php new config option do-remember; solution for #12 2024年01月04日 21:42:49 +01:00
post changed phps short open tag to long open tag 2023年10月26日 18:21:19 +02:00
README.md new config option: do-post ( #12 ) 2023年12月01日 14:31:02 +01:00
rss2bsky.php fix for new config option do-remember; solution for #12 2024年01月04日 21:53:38 +01:00
test improved image detection for card generation; possible solution for #16 2024年01月04日 21:31:16 +01:00

rss2bsky

CCBY4

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-directory
  • mkdir lib
  • mkdir cache
  • chown www-data.www-data cache (assuming your webserver runs as www-data; adjust if necessary)
  • copy or link SimplePie.compiled.php to lib/SimplePie.compiled.php (/usr/share/php/simplepie/SimplePie.compiled.php or 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)

CC BY