Package Data | |
---|---|
Maintainer Username: | revolution |
Maintainer Contact: | kawaxbiz@gmail.com (kawax) |
Package Create Date: | 2017-05-10 |
Package Last Update: | 2024-11-21 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-23 03:25:22 |
Package Statistics | |
---|---|
Total Downloads: | 30,716 |
Monthly Downloads: | 494 |
Daily Downloads: | 6 |
Total Stars: | 25 |
Total Watchers: | 4 |
Total Forks: | 2 |
Total Open Issues: | 0 |
composer require revolution/laravel-mastodon-api
use 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' => '',
//]
}
}
Use https://github.com/kawax/socialite-mastodon
Save account info.(id
, token
, username
, acct
...and more.)
$statuses = Mastodon::domain('https://example.com')
->token('token')
->statuses($account_id);
dd($statuses);
$status = Mastodon::domain('https://example.com')
->token('token')
->status($status_id);
dd($status);
Mastodon::domain('https://example.com')->token('token');
$response = Mastodon::createStatus('test1');
$response = Mastodon::createStatus('test2', ['visibility' => 'unlisted']);
dd($response);
get
or post
method$response = Mastodon::domain('https://example.com')
->token('token')
->get('/timelines/public', ['local' => true]);
$response = Mastodon::domain('https://example.com')
->token('token')
->post('/follows', ['uri' => '']);
call
method$response = Mastodon::domain('https://example.com')
->token('token')
->call('DELETE', '/statuses/1');
Set all data by your self.
$url = 'https://example.com/api/v1/instance';
$options = [
'headers' => [
'Authorization' => 'Bearer ' . $token,
]
]
$response = Mastodon::request('GET', $url, $options);
dd($response);
use GuzzleHttp\Client;
use Revolution\Mastodon\MastodonClient;
$mastodon = new MastodonClient(new Client);
$statuses = $mastodon->domain('https://example.com')
->token('token')
->statuses($account_id);
Check public methods in Contracts/Factory.php
Edit $token
and $url
in streaming_example.php
php ./streaming_example.php
Ctrl+C
to quit.
MIT
Copyright kawax