Skip to content

Piero Bosio Social Web Site Personale Logo Fediverso

Social Forum federato con il resto del mondo. Non contano le istanze, contano le persone

Updates to ActivityPub in a single PHP file

General Discussion
3 3 0
  • Updates to ActivityPub in a single PHP file

    https://shkspr.mobi/blog/2024/03/updates-to-activitypub-in-a-single-php-file/

    A few weeks ago, I built an ActivityPub Server in a Single PHP File. It's a proof of concept showing how easy it is to turn a website into a full-featured Fediverse participant.

    After a bunch of feedback and testing, I've added a some features to make it slightly more useful.

    • A single PHP file - 45KB of no-library goodness. Just add your details, upload, and done.
    • No databases. Everything stored as JSON files on disk.
    • Be followed. External users can discover and follow you.
    • Send messages. You can send messages to all your followers.
    • πŸ†• Follow users. You can follow other Fediverse actors.
    • πŸ†• Read messages. You can read the messages sent to your Inbox. If media is attached, those will be displayed.
    • πŸ†• Verify signatures. ActivityPub messages can by cryptographically signed. This now verifies those signatures.

    You can grab the code here - pull requests welcome. If you want to see what it looks like in action, visit https://example.viii.fi/ or follow @example@example.viii.fi.

    Again, to re-emphasise what it says in the README - this is not suitable for production use. This is primarily a way to explain all the different functions of an ActivityPub server. It is adequately commented and I hope a moderately competent programmer could follow what's going on. It is almost certainly insecure and is considered harmful to aquatic life.

    I would be delighted if you took the code and did something interesting with it. Perhaps create a single-file server in your favourite language?

    ToDo

    A few random things which I might add - or which you might consider making and sending a Pull Request:

    • Better UI. It is deliberately bare-bones, see the /read interface. But perhaps there's a simpler way to make it look nice?
    • No threading in the UI - and no ability to reply to messages.
    • Support for reading hashtagged posts on the site.
    • Reply highlighting - at the moment you can't see if a message was sent to you.
    • Some Fediverse posts contain polls, content warnings, and other extended features. That could be fun to support - both for reading and writing.
    • Support for reading custom emoji.
    • Deletes, Updates, and Undos are received - but it currently doesn't remove the previously saved file.
    • There's no way to unfollow a user - except for manually deleting data from the file-system.
    • Only supports one image upload. Could support more? Or even other media?
    • I don't think CC works properly.
    • Message visibility could be useful.
    • Boring stuff like better error handling.

    If you have opinions, please let me know!

  • Updates to ActivityPub in a single PHP file

    https://shkspr.mobi/blog/2024/03/updates-to-activitypub-in-a-single-php-file/

    A few weeks ago, I built an ActivityPub Server in a Single PHP File. It's a proof of concept showing how easy it is to turn a website into a full-featured Fediverse participant.

    After a bunch of feedback and testing, I've added a some features to make it slightly more useful.

    • A single PHP file - 45KB of no-library goodness. Just add your details, upload, and done.
    • No databases. Everything stored as JSON files on disk.
    • Be followed. External users can discover and follow you.
    • Send messages. You can send messages to all your followers.
    • πŸ†• Follow users. You can follow other Fediverse actors.
    • πŸ†• Read messages. You can read the messages sent to your Inbox. If media is attached, those will be displayed.
    • πŸ†• Verify signatures. ActivityPub messages can by cryptographically signed. This now verifies those signatures.

    You can grab the code here - pull requests welcome. If you want to see what it looks like in action, visit https://example.viii.fi/ or follow @example@example.viii.fi.

    Again, to re-emphasise what it says in the README - this is not suitable for production use. This is primarily a way to explain all the different functions of an ActivityPub server. It is adequately commented and I hope a moderately competent programmer could follow what's going on. It is almost certainly insecure and is considered harmful to aquatic life.

    I would be delighted if you took the code and did something interesting with it. Perhaps create a single-file server in your favourite language?

    ToDo

    A few random things which I might add - or which you might consider making and sending a Pull Request:

    • Better UI. It is deliberately bare-bones, see the /read interface. But perhaps there's a simpler way to make it look nice?
    • No threading in the UI - and no ability to reply to messages.
    • Support for reading hashtagged posts on the site.
    • Reply highlighting - at the moment you can't see if a message was sent to you.
    • Some Fediverse posts contain polls, content warnings, and other extended features. That could be fun to support - both for reading and writing.
    • Support for reading custom emoji.
    • Deletes, Updates, and Undos are received - but it currently doesn't remove the previously saved file.
    • There's no way to unfollow a user - except for manually deleting data from the file-system.
    • Only supports one image upload. Could support more? Or even other media?
    • I don't think CC works properly.
    • Message visibility could be useful.
    • Boring stuff like better error handling.

    If you have opinions, please let me know!

    @blog @example

    Love this project!

    Was skimming the project README and that last requirements line got me πŸ˜„

  • @blog Thanks! Much respect for just getting this out there. Love the comments! πŸ˜‚


Gli ultimi otto messaggi ricevuti dalla Federazione
Post suggeriti
  • 0 Votes
    1 Posts
    10 Views
    Don't miss this keynote by @cwebber and John D. Boy! > #SocialMedia: We Can Change the DefaultsπŸ“… Th. 27 Nov. 2025 at 8 pmonline and #Amsterdam> @cwebber, … co-author of #ActivityPub, … will speak about the crisis technologists face. Why must we revise the default assumptions of the web 2.0 era? She will introduce the work @spritelysocial.coop is doing to make a positive future possible. #SPUI25 #SaveSocial #Fediverse #OpenSource #FOSS #sovereignty #EuSummit25
  • 0 Votes
    1 Posts
    6 Views
    Now witness the power of this fully operational Fediverse!https://shkspr.mobi/blog/2025/11/now-witness-the-power-of-this-fully-operational-fediverse/How can you measure the popularity of a social network site? Perhaps by counting the number of active accounts, or the quality of the discourse, or even how many people reply to your witty memes.Me? I prefer to look at how many people visit my blog from each site. It is an imperfect measure - and a vain one - but lets me know where I should be spending my time. No point posting on a network which is just bots talking to each other, right?Earlier this year I built a stats-counter for my blog. Every time someone clicks from a website which links to my blog, it records that visit in a database. I get to see which blog posts are doing numbers, and where those numbers came from.Until fairly recently, the Mastodon social network didn't send referer details. I thought that reduced the visibility of the network and lobbied for it to change. As various Mastodon servers upgrade, and admins opt-in, it is becoming more apparent just how much traffic originates from the Fediverse.Over the last few weeks, here's how many people have clicked from BlueSky and Mastodon to one of my blog posts.TotalSource1,607bsky.app752mastodon.socialAt first glance, it doesn't look good for our elephantine friends, does it? The butterfly sends over twice the traffic. Game over!But, of course, while Mastodon.social is the biggest instance - it is far from the only one. What happens if we slide down the long tail? Here's all the Mastodon-ish instances which sent me over 10 clicks.TotalSource193phanpy.social120 android-app://org.joinmastodon.android/106infosec.exchange62mas.to59mstdn.social55social.vivaldi.net49wandering.shop48fosstodon.org33mathstodon.xyz27mastodon.online26mastodon.scot24app.wafrn.net19indieweb.social18social.lol17tech.lgbt17toot.wales16en.osm.town16feditrends.com14mstdn.ca14piefed.social12wetdry.world11c.im11mastodon.nl51 Sites sending < 10 clicksAh! Add them all up and you get a grand total of 1,773 visitors from Mastodon-powered sites. That's more than BlueSky.Now, there are some obvious caveats to the data:I have a smaller follower count on BlueSky than I do on Mastodon.My posts may appeal more to one demographic than another.People may have strict privacy controls which suppress the true volume of visitors.There's no way to measure how long someone spends reading my posts.RSS and newsletter visitors aren't counted.Clicks from apps may not always show a referer.Some people may be on multiple services.Fediverse users can follow the post directly, so don't need to visit the site to read it.And yet… no matter how you slice it, Fediverse servers are sending as much traffic as BlueSky!I think this is brilliant. Web services should be able to scale from small to big - and each ActivityPub-powered site helps power the open Internet.Just for completeness, this is how Reddit, Facebook, LinkedIn, Twitter, and Lemmy do over the same period:TotalSource1,158reddit.com585 android-app://com.reddit.frontpage/76facebook.com76https://old.reddit.com/r/programming/56https://www.reddit.com/r/programming/52youtube.com41t.co38https://old.reddit.com/r/todayilearned/comments/1nsw7f4/til_in_mongolia_instead_of_a_street_address_a/31linkedin.com27 android-app://io.syncapps.lemmy_sync/27https://www.reddit.com/r/todayilearned/comments/1nsw7f4/til_in_mongolia_instead_of_a_street_address_a/22https://old.reddit.com/r/programming/comments/1n96ftn/40_years_later_are_bentleys_programming_pearls/22lemmy.ca17 android-app://com.linkedin.android/16lemmy.dbzer0.com14feddit.org11https://www.reddit.com/r/programming/comments/1n96ftn/40_years_later_are_bentleys_programming_pearls/10discuss.tchncs.de10l.instagram.com8lemmy.blahaj.zone6https://www.reddit.com/r/GrapheneOS/comments/1m2l84b/considering_making_the_switch_does_google_pay/6reddthat.comIf you add up all the Lemmy instances, they send about as much traffic as Facebook and LinkedIn combined. That's not a huge surprise - those platforms hate anyone clicking away to the wider web.Twitter is basically the Dead Internet. I'm no longer on there, but I do occasionally search it to see who is sharing my posts. The popular posts I write get shared a lot - sometimes by accounts with huge followers - yet there are no comments or retweets and barely and clicks.I don't do Instagram or Threads, and that might be reflected in their low numbers. But I'm not active on YouTube either - yet people there occasionally link back to me.Final ThoughtsFirstly, my stats only represent my site. Your site might be very different.Secondly, I've ignored search engine traffic, big blogs, newsletters, and other sources.Thirdly, and most importantly, this isn't a competition! The desire for a "winner-takes-all" service is dangerous and disturbing. An ecosystem is at its most vibrant when there are multiple participants each thriving in their own niche.I want a thousand sites, running a hundred different software stacks, some of which only serve a dozen people, or even a lone participant.Diversity is strength.#activitypub #bluesky #fediverse #mastodon #statistics
  • 0 Votes
    1 Posts
    10 Views
    No, am not particularly worried about my government reading my posts. Not if it requires Kristi Noem to understand #activitypub.
  • 0 Votes
    1 Posts
    16 Views
    Week in Fediverse 2025-10-24Servers- Betula v1.5.0- Vernissage Server v1.25.0- Mastodon v4.4.8- Ktistec v3.1.1- Wafrn v2025.10.01- Mobilizon v5.2.0- Misskey v2025.10.1- NeoDB v0.12.4- Merp Relay v0.3.0- comments: Server component for comment tracking systemsClients- IceCubesApp v2.0.8- Mangane v1.18.1- Photon v2.1.1- Blorp v1.9.26Tools and Plugins- Poduptime v5.5.4- Fediverse follows quiz- Vulpes Porto: Bot to post remotely or locally hosted photos daily at set timesFor developers- Fedialgo v1.2.23- apkit v0.3.3- roboherd v0.1.12Protocol- Server-Sent Events For the ActivityPub APIArticles- Understanding Decentralized Social Feed Curation on Mastodon- Fediverse Report #139-----#WeekInFediverse #Fediverse #ActivityPubPrevious edition: https://mitra.social/objects/0199f3d4-c2ce-a6c6-de48-dcb254582434