承接 revolution/laravel-mastodon-api 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

revolution/laravel-mastodon-api

最新稳定版本:3.4.0

Composer 安装命令:

composer require revolution/laravel-mastodon-api

包简介

Mastodon API for Laravel

README 文档

README

Ask DeepWiki

Requirements

  • PHP >= 8.2
  • Laravel >= 11.0

Installation

Composer

composer require revolution/laravel-mastodon-api

Socialite and Notification packages will also be installed.

Usage

Registering an application

By Web UI

  1. Go to your Mastodon's user preferences page.
  2. 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

统计信息

  • 总下载量: 64.53k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 27
  • 点击次数: 2
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 26
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-10