zonuexe / mastodon-api
Mastodon 的 PHP 接口。
0.0.6
2017-05-29 16:21 UTC
Requires
- guzzlehttp/guzzle: ^6.2
- respect/validation: ^1.1
- zonuexe/objectsystem: ^0.6.0
Requires (Dev)
- filp/whoops: ^2.1
- monolog/monolog: ^1.22
- paragonie/random_compat: ^2.0
- phpmd/phpmd: ^2.6
- phpunit/phpunit: ^4.8
- symfony/polyfill-php70: ^1.3
- symfony/var-dumper: ^3.2
- vlucas/phpdotenv: ^2.4
- zonuexe/simple-routing: ^0.5.3
Suggests
- vlucas/phpdotenv: Load .env format config file
This package is not auto-updated.
Last update: 2024-09-15 01:07:18 UTC
README
安装
$ composer require zonuexe/mastodon-api
要求
- PHP 5.5, 5.6, 7.0, 7.1, HHVM
- Composer
特性
- IDE (PhpStorm) 友好的类/函数定义
- 支持 多范式编程 风格(过程式 vs OOP)
使用方法
简单的过程式风格
<?php use Baguette\Mastodon as m; $service = m\session( 'pawoo.net', $client_id, $client_secret, [ 'scope' => 'read write follow', 'grant' => ['username' => $username, 'password' => $password], ] ); // Get account by ID $account = $service->getAccount(42); // Toot! $status = $service->postStatus(m\toot('トゥートゥー'));
手动 API 请求
如果您想请求此 SDK 中未实现的 API,您可以手动编写请求。这种方法在请求特定实例的 API 时也非常有用。
<?php use Baguette\Mastodon as m; $service = m\session( 'pawoo.net', $client_id, $client_secret, [ // ... ] ); /** @var m\Entity\Account */ $entity = m\request($service, 'GET', '/api/v1/accounts/29', [], m\Entity\Account::class); // If you are a PhpStorm user, you can safely type the variable in the action of `/** @var */`. // Probably the following code will be fill with methods and properties by code completion. $entity->█
实现状态
- GET /api/v1/accounts/:id
Account Mastodon::getAccount(int $id)
- GET /api/v1/accounts/verify_credentials
Account Mastodon::getAccountCurrentUser()
- PATCH /api/v1/accounts/update_credentials
Account Mastodon::updateAccount(array $update_data)
- GET /api/v1/accounts/:id/followers
Account[] getAccountFollowers(int $account_id)
- GET /api/v1/accounts/:id/following
- GET /api/v1/accounts/:id/statuses
- POST /api/v1/accounts/:id/follow
- POST /api/v1/accounts/:id/unfollow
- GET /api/v1/accounts/:id/block
- GET /api/v1/accounts/:id/unblock
- GET /api/v1/accounts/:id/mute
- GET /api/v1/accounts/:id/unmute
- GET /api/v1/accounts/relationships
- GET /api/v1/accounts/search
- POST /api/v1/apps
- GET /api/v1/blocks
Account[] getBlocks(array $options = [])
- GET /api/v1/favourites
Status[] getFavourites(array $options = [])
- GET /api/v1/follow_requests
Account[] getFollowRequests(array $options = [])
- POST /api/v1/follow_requests/:id/authorize
- POST /api/v1/follow_requests/:id/reject
- POST /api/v1/follows
- GET /api/v1/instance
- POST /api/v1/media
- GET /api/v1/mutes
- GET /api/v1/notifications
- GET /api/v1/notifications/:id
- POST /api/v1/notifications/clear
- GET /api/v1/reports
- POST /api/v1/reports
- GET /api/v1/search
- GET /api/v1/statuses/:id
Status getStatus($status_id)
- GET /api/v1/statuses/:id/context
- GET /api/v1/statuses/:id/card
- GET /api/v1/statuses/:id/reblogged_by
- GET /api/v1/statuses/:id/favourited_by
- POST /api/v1/statuses
Status Mastodon::postStatus(Toot $toot)
- DELETE /api/v1/statuses/:id
- POST /api/v1/statuses/:id/reblog
- POST /api/v1/statuses/:id/unreblog
- POST /api/v1/statuses/:id/favourite
- POST /api/v1/statuses/:id/unfavourite
- GET /api/v1/timelines/home
- GET /api/v1/timelines/public
- GET /api/v1/timelines/tag/:hashtag
版权
Baguette\Mastodon 基于 GNU 通用公共许可证,版本 3.0 授权。见 ./LICENSE
。
Baguette Mastodon - Mastodon API Client for PHP
Copyright (c) 2016 Baguette HQ / USAMI Kenta <tadsan@zonu.me>