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

colorfield/mastodon: Mastodon module for Drupal 8

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

开源软件名称(OpenSource Name):

colorfield/mastodon

开源软件地址(OpenSource Url):

https://github.com/colorfield/mastodon

开源编程语言(OpenSource Language):

PHP 93.3%

开源软件介绍(OpenSource Introduction):

Configuration

Configure OAuth at /admin/config/services/mastodon

  1. The configuration form will provide, by default: a client_id, client_secret and authorization URL.
  2. Go to the authorization URL, confirm access, copy the authorization code and save configuration.
  3. The form will autocomplete the bearer from the access token, re-save configuration then.

A test of the API will be displayed, getting followers from the user 1 of your instance.

Using the API

The Mastodon class is available as a Drupal service that uses OAuth credentials defined from the configuration, in the constructor.

Get it via dependency injection ('mastodon.api') then it is ready to use.

$user = $mastodon->authenticateUser($email, $password);

Or use the static service container when dependency injection is not available.

$mastodon = \Drupal::service('mastodon.api');
$user = $mastodon->authenticateUser($email, $password);

Option 1 - use the Mastodon API

You can still use the API endpoints defined via the Mastodon API documentation.

Currently the scopes are defined as read and write (without follow).

$user_id = 1;
$followers = $mastodon->getApi()->get('/accounts/'.$user_id.'/followers',
 ['limit' => 2]);

Option 2 - rely on the Mastodon wrapper

Currently methods are being implemented as a syntactic sugar #2920985.

$user_id = 1;
$followers = $mastodon->getFollowers($user_id, ['limit' => 2]);

Methods to be implemented

Project status for the Mastodon wrapper, by release.

Accounts
Description Endpoint Needs auth  Release Status
Fetching an account GET /api/v1/accounts/:id 1.0
Getting the current user GET /api/v1/accounts/verify_credentials 1.0
Updating the current user PATCH /api/v1/accounts/update_credentials
Getting an account's followers GET /api/v1/accounts/:id/followers 1.0
Getting who account is following GET /api/v1/accounts/:id/following 1.0
Getting an account's statuses GET /api/v1/accounts/:id/statuses 1.0
Following/unfollowing an account POST /api/v1/accounts/:id/follow - unfollow
Blocking/unblocking an account POST /api/v1/accounts/:id/block - unblock
Muting/unmuting an account POST /api/v1/accounts/:id/mute - unmute
Getting an account's relationships GET /api/v1/accounts/relationships 1.0
Searching for accounts GET /api/v1/accounts/search 1.0
Apps
Description Endpoint Needs auth  Release Status
Registering an application POST /api/v1/apps 1.0
Blocks
Description Endpoint Needs auth  Release Status
Fetching a user's blocks GET /api/v1/blocks
Domain blocks
Description Endpoint Needs auth  Release Status
Fetching a user's blocked domain GET /api/v1/domain_block
Blocking a domain POST /api/v1/domain_block
Unblocking a domain DELETE /api/v1/domain_block
Favourites
Description Endpoint Needs auth  Release Status
Fetching a user's favourites GET /api/v1/favourite
Follow Requests
Description Endpoint Needs auth  Release Status
Fetching a list of follow requests GET /api/v1/follow_requests
Authorizing or rejecting follow requests POST /api/v1/follow_requests/:id/authorize - reject
Follow
Description Endpoint Needs auth  Release Status
Following a remote user POST /api/v1/follows
Instances
Description Endpoint Needs auth  Release Status
Getting instance information GET /api/v1/instance
Medias
Description Endpoint Needs auth  Release Status
Uploading a media attachment POST /api/v1/media
Mutes
Description Endpoint Needs auth  Release Status
Fetching a user's mutes GET /api/v1/mutes
Notifications
Description Endpoint Needs auth  Release Status
Fetching a user's notification GET /api/v1/notifications
Getting a single notificatio GET /api/v1/notifications/:id
Clearing notifications POST /api/v1/notifications/clear
Dismissing a single notification POST /api/v1/notifications/dismiss
Reports
Description Endpoint Needs auth  Release Status
Fetching a user's reports GET /api/v1/reports
Reporting a user POST /api/v1/reports
Search
Description Endpoint Needs auth  Release Status
Searching for content GET /api/v1/search 1.0
Statuses
Description Endpoint Needs auth  Release Status
Fetching a status GET /api/v1/statuses/:id
Getting status context GET /api/v1/statuses/:id/context
Getting a card associated with a status GET /api/v1/statuses/:id/card
Getting who reblogged/favourited a status GET /api/v1/statuses/:id/reblogged_by - favourited_by
Posting a new status POST /api/v1/statuses
Deleting a status DELETE /api/v1/statuses/:id
Reblogging/unreblogging a status POST /api/v1/statuses/:id/reblog - unreblog
Favouriting/unfavouriting a status POST /api/v1/statuses/:id/favourite - unfavourite
Muting/unmuting a conversation of a status POST /api/v1/statuses/:id/mute - unmute
Timelines
Description Endpoint Needs auth  Release Status
Retrieving a timeline GET /api/v1/timelines/home 1.0
Retrieving a timeline GET /api/v1/timelines/public 1.0
Retrieving a timeline GET /api/v1/timelines/tag/:hashtag 1.0

@todo streaming api https://github.com/tootsuite/documentation/blob/master/Using-the-API/Streaming-API.md




鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
drikin/mastodon发布时间:2022-08-18
下一篇:
gstml/mastodon: re-CSS of the Mastodon web interface发布时间:2022-08-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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