Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.
/ flarum-api-client Public archive

The API client for working with your Flarum forum.

License

Notifications You must be signed in to change notification settings

flagrow/flarum-api-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flarum-api-client by flagrow logo flagrow

Latest Stable Version Gitter

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.

installation

composer require flagrow/flarum-api-client

configuration

In order to start working with the client you might need a Flarum master key:

  1. Generate a 40 character random, unguessable string, this is the Token needed for this package.
  2. Manually add it to the api_keys table using phpmyadmin/adminer or another solution.

The master key is required to access non-public discussions and running actions otherwise reserved for Flarum administrators.

examples

A basic example:

<?php

require_once "vendor/autoload.php";

use Flagrow\Flarum\Api\Flarum;

$api = new Flarum('http://example.com');

// A collection of discussions from the first page of your Forum index.
$discussions = $api->discussions()->request();
// Read a specific discussion.
$discussion = $api->discussions()->id(1)->request();
// Read the first page of users.
$users = $api->users()->request();

An authorized example:

$api = Flarum('http://example.com', ['token' => '<insert-master-token>; 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.

links

Flagrow is a collaboration of Flarum extension developers to provide quality, maintained extensions.

About

The API client for working with your Flarum forum.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages