User Tools

Site Tools


Open Source Social Media: An overview of Mastodon and ActivityPub

A short talk and Q&A on the future of open source social media.

When Tue September 17th 2019, 6:30pm
Where The Avalon Lounge, Kent Road



Name Fediverse URL
Abe Stewart
Brian Hunter
David Taylor
Neil McKillop
Rowan Evenstar
Sophia Davis
Zoe Gadon-Thompson

Example code

This is a cronjob that runs every 5 minutes.

// Ihis is a simple example of feeding data into the Fediverse
// It takes GlasgowLive's RSS feed, checks what's new and toots it (as
// Include the Mastodon API and set up the connection credentials
require "vendor/autoload.php";
require "config/glasgowlive_credentials.php";
// Make a connection to the Fediverse
$oAuth = new Colorfield\Mastodon\MastodonOAuth($name, $instance);
$mastodonAPI = new Colorfield\Mastodon\MastodonAPI($oAuth->config);
// Download the GlasgowLive RSS feed
$url = "";
$data = file_get_contents($url);
$data = simplexml_load_file($url);
// Iterate through the data, check if we've mentioned it already,
// otherwise it's new - make a toot!
foreach($data->channel->item as $key=>$item) {
   $title = $item->title;
   $link = $item->link;
   $id = $item->guid;
   // Check the database for a note that this article has been tooted
   $stmt = $db->prepare("select * from rss_tracker where type=? and uniq_link=?");
   $row = $stmt->fetch();
   // if we don't find it, then toot and record to the database that we've tooted
   if(!$row) {
      $string = "$title\n$link";
      $params['status'] = $string;
      $params['visibility'] = "unlisted";
      if($post = $mastodonAPI->post('/statuses', $params)) {
         $insert_stmt = $db->prepare("insert into rss_tracker set uniq_link=?, type=?");
         $insert_stmt->execute([$link, $type]);
2019-09-17.1568732445.txt.gz · Last modified: 2019/09/17 16:00 by nmckillop