2017 © Pedro Peláez
 

library laravel-mastodon-api

Mastodon API for Laravel

image

revolution/laravel-mastodon-api

Mastodon API for Laravel

  • Thursday, May 17, 2018
  • by revolution
  • Repository
  • 1 Watchers
  • 4 Stars
  • 238 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 25 % Grown

The README.md

Mastodon API for Laravel

Requirements

  • PHP >= 8.2
  • Laravel >= 11.0

Installation

Composer

composer require revolution/laravel-mastodon-api

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/kawax/socialite-mastodon, (*1)

Save account info.(id, token, username, acct...and more.), (*2)

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, (*3)

Streaming API

Edit $token and $url in streaming_example.php, (*4)

php ./streaming_example.php

Ctrl+C to quit., (*5)

LICENSE

MIT, (*6)

The Versions

17/05 2018

dev-master

9999999-dev

Mastodon API for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by kawax

laravel mastodon

17/05 2018

1.5.1

1.5.1.0

Mastodon API for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by kawax

laravel mastodon

17/05 2018

1.5.0

1.5.0.0

Mastodon API for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by kawax

laravel mastodon

11/11 2017

1.4.0

1.4.0.0

Mastodon API for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by kawax

laravel mastodon

09/11 2017

1.3.2

1.3.2.0

Mastodon API for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by kawax

laravel mastodon

09/11 2017

1.3.1

1.3.1.0

Mastodon API for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by kawax

laravel mastodon

12/10 2017

1.3.0

1.3.0.0

Mastodon API for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by kawax

laravel mastodon

14/09 2017

1.2.0

1.2.0.0

Mastodon API for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by kawax

laravel mastodon

04/08 2017

1.1.4

1.1.4.0

Mastodon API for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by kawax

laravel mastodon

30/05 2017

1.1.3

1.1.3.0

Mastodon API for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by kawax

laravel mastodon

14/05 2017

1.1.2

1.1.2.0

Mastodon API for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by kawax

laravel mastodon

14/05 2017

1.1.1

1.1.1.0

Mastodon API for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by kawax

laravel mastodon

14/05 2017

1.1.0

1.1.0.0

Mastodon API for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by kawax

laravel mastodon

10/05 2017

1.0.0

1.0.0.0

Mastodon API for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by kawax

laravel mastodon