revolution/laravel-mastodon-api
Composer 安装命令:
composer require revolution/laravel-mastodon-api
包简介
Mastodon API for Laravel
README 文档
README
Requirements
- PHP >= 8.3
- Laravel >= 12.0
Installation
Composer
composer require revolution/laravel-mastodon-api
Socialite and Notification packages will also be installed.
Usage
Registering an application
By Web UI
- Go to your Mastodon's user preferences page.
- Go to development page.
By API
use Revolution\Mastodon\Facades\Mastodon; class MastodonController { public function app() { $client_name = 'my-app'; $redirect_uris = 'https://my-instance/callback'; $scopes = 'read write follow'; $app_info = Mastodon::domain('https://example.com') ->createApp($client_name, $redirect_uris, $scopes); dd($app_info); //[ // 'id' => '', // 'client_id' => '', // 'client_secret' => '', //] } }
OAuth authentication
Use https://github.com/invokable/socialite-mastodon
Save account info.(id, token, username, acct...and more.)
Get statuses
use Revolution\Mastodon\Facades\Mastodon; $statuses = Mastodon::domain('https://example.com') ->token('token') ->statuses($account_id); dd($statuses);
Get one status
use Revolution\Mastodon\Facades\Mastodon; $status = Mastodon::domain('https://example.com') ->token('token') ->status($status_id); dd($status);
Post status
use Revolution\Mastodon\Facades\Mastodon; Mastodon::domain('https://example.com')->token('token'); $response = Mastodon::createStatus('test1'); $response = Mastodon::createStatus('test2', ['visibility' => 'unlisted']); dd($response);
Any API by get or post method
use Revolution\Mastodon\Facades\Mastodon; $response = Mastodon::domain('https://example.com') ->token('token') ->get('/timelines/public', ['local' => true]);
use Revolution\Mastodon\Facades\Mastodon; $response = Mastodon::domain('https://example.com') ->token('token') ->post('/follows', ['uri' => '']);
Any API can call by call method
use Revolution\Mastodon\Facades\Mastodon; $response = Mastodon::domain('https://example.com') ->token('token') ->call('DELETE', '/statuses/1');
Other methods
Check public methods in Contracts/Factory.php
Streaming API
Edit $token and $url in streaming_example.php
php ./streaming_example.php
Ctrl+C to quit.
LICENSE
MIT
revolution/laravel-mastodon-api 适用场景与选型建议
revolution/laravel-mastodon-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 80.83k 次下载、GitHub Stars 达 26, 最近一次更新时间为 2017 年 05 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「mastodon」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 revolution/laravel-mastodon-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 revolution/laravel-mastodon-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 revolution/laravel-mastodon-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Socialite for Mastodon
A boilerplate library for Mastodon bots.
First-class Notifications for Craft CMS.
Mastodon OAuth 2.0 support for the PHP League's OAuth 2.0 Client
Mastodon PHP library oAuth and API
Alfabank REST API integration
统计信息
- 总下载量: 80.83k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 27
- 点击次数: 14
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-05-10