PHP code example of zonuexe / mastodon-api

1. Go to this page and download the library: Download zonuexe/mastodon-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zonuexe / mastodon-api example snippets




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('トゥートゥー'));



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->█