flarum-api-client by flagrow
This is a generic PHP API client for use in any project. You can simply include this package as a dependency to your project to use it.
- Improve coverage of all functionality in Flarum.
For this package we will implement new calls based on your requests. Please submit them in the issue tracker on Github.
For a complete overview of our releases, please visit the milestones tracker on Github.
composer require flagrow/flarum-api-client
In order to start working with the client you might need a Flarum master key:
- Generate a 40 character random, unguessable string, this is the Token needed for this package.
- Manually add it to the
api_keys table using phpmyadmin/adminer or another solution.
A basic example:
$api = new Flagrow\Flarum\Api\Flarum('http://example.com');
// Load discussion with Id 1:
$discussion = $api->discussions()->id(1)->request();
// Load the first page of discussions:
$discussions = $api->discussions()->request();
An authorized example:
$api = new Flagrow\Flarum\Api\Flarum('http://example.com/api/', ['token' => 'randomtoken; userId=1']);
The userId refers to a user that has admin permissions or the user you want to run actions for. Appending the userId setting to the token only works for Master keys.
Flagrow is a collaboration of Flarum extension developers to provide quality, maintained extensions.