luceos I tried to composer "flagrow/flarum-api-client", but it couldn't download files completely. So I turned to git clone 'flagrow/flarum-api-client' instead.
I inserted a random master-key in api-key table, and then ran the script based on basic example, but I got the error message below:
==
PHP Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: GET http://localhost/forum/api/discussions
resulted in a 404 Not Found
response:
<html>
<head><title>404 - No Such Resource</title></head>
<body>
<h1>No Such Resource</h1>
<p>No such child (truncated...)
in /home/wmchen/www/forum/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /home/wmchen/www/forum/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /home/wmchen/www/forum/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /home/wmchen/www/forum/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#3 /home/wmchen/www/forum/vendor/guzzlehttp/promises/src/Tas in /home/wmchen/www/forum/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113
==
Did I got anything wrong?
Here is my script:
<?php
require_once "vendor/autoload.php";
use Flagrow\Flarum\Api\Flarum;
$api = new Flarum('http://localhost/forum', ['token' => 'YACub3KLfe8mfmHPcUKtt6t2SMJOGPXnZbqhc3nX; userId=1']);
// 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();
var_dump($users);
?>