User Tools

Site Tools


events:2019-09-17

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

Attendees

(ref)

Name Fediverse URL
Brian Hunterhttps://glasgow.social/@bhlm
David Taylor
Neil McKillop https://glasgow.social/@neil
Steven https://glasgow.social/@M

Signed up, but didn't show

Abe Stewart
Gabriele
Hammy https://glasgow.social/@Hammy
Rosa
Rowan Evenstar
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 GlasgowLive@glasgow.social)
 
// 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);
$oAuth->config->setClientId($client_id);
$oAuth->config->setClientSecret($client_secret);
$oAuth->config->setBearer($bearer);
$mastodonAPI = new Colorfield\Mastodon\MastodonAPI($oAuth->config);
 
// Download the GlasgowLive RSS feed
$url = "https://www.glasgowlive.co.uk/?service=rss";
$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=?");
   $stmt->execute([$type,$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]);
      }
   }
}
events/2019-09-17.txt · Last modified: 2019/10/04 13:31 by admin