• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

aaronpk/Nautilus: Turn your website into an ActivityPub profile

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

aaronpk/Nautilus

开源软件地址(OpenSource Url):

https://github.com/aaronpk/Nautilus

开源编程语言(OpenSource Language):

PHP 97.4%

开源软件介绍(OpenSource Introduction):

Nautilus

This project is meant to run as a standalone service to deliver posts from your own website to ActivityPub followers. You can run your own website at your own domain, and this service can handle the ActivityPub-specific pieces needed to let people follow your own website from Mastodon or other compatible services.

Setup

These instructions assume you've deployed this proxy service to proxy.example.com and that your primary domain that you want to use for your ActivityPub identity is example.com.

Create a user account in this service

$ php artisan user:create username email name

Fetch the JSON profile from this service to serve on your domain

$ curl https://proxy.example.com/username.json

Save that file on your own website in a file named:

https://example.com/.well-known/user.json

Save the below as a file named: https://example.com/.well-known/host-meta

<?xml version="1.0"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
  <Link rel="lrdd" type="application/xrd+xml" template="https://example.com/.well-known/user.json?resource={uri}"/>
</XRD>

In order for the permalinks of your posts to also live on your domain, you'll need to create an HTTP redirect rule from your server to this service. In nginx, you can create a rewrite rule such as this:

rewrite ^/activitypub/(.+) https://proxy.example.com/username/$1;

Your posts will be identified with a URL on your own domain this way, so that you continue to own the permalinks. This rewrite is required in order for Mastodon and other servers to be able to fetch the JSON version of your posts.

Running

This project uses the Laravel framework. Please refer to the Laravel Configuration Guide for more details.

You'll need to copy .env.example to .env and set up your database connection and queue driver there. It is recommended to use an asynchronous queuing driver such as redis or database, otherwise your server may time out if you have many followers.

Once your queue and database are configured, you can run the worker in the background via:

$ php artisan queue:work

Usage

Following

Once your domain is configured to delegate the ActivityPub profile bits to this service, you can now be followed by people on Mastodon. They will be able to search for yourusername@example.com and click "Follow".

Delivery

To create a post to deliver to all your followers, you'll need to create a token that you can use to tell this service to deliver a post. From the command line, run:

$ php artisan token:generate yourusername

This will output a new token you can use in a request.

To create a post and deliver it to your followers, send a POST request with the token to this service's post creation endpoint. For example:

$ch = curl_init('https://proxy.example.com/yourusername/micropub');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  'Authorization: Bearer xxxxxxxxxxxxxxxxxxx'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
  'h' => 'entry',
  'content' => 'The content of your post'
]);
curl_exec($ch);

The background worker will deliver the post to all of your followers.

Todo

This is currently a pretty barebones ActivityPub implementation. There are still a few things needed to turn this into a full ActivityPub proxy service.

  • Include photos and videos in posts
  • Support creating replies
  • Support creating likes
  • Support creating reposts
  • Support updating existing posts
  • Support deleting posts
  • Follow other users
  • Deliver posts created by people you follow into somewhere you can read them - likely by pushing them into an Aperture channel, or providing a feed you can subscribe to in an RSS reader
    • Note that I will not implement this as a single feed, but rather you'll be able to group people you follow into different channels, since a single timeline is unsustainable



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap