1. Go to this page and download the library: Download pnz/mattermost-client 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/ */
pnz / mattermost-client example snippets
bash
composer
php
= 'http://mattermostserver.ext/api/v4';
$username = 'username';
$password = 'password';
$configurator = (new HttpClientConfigurator())
->setEndpoint($endpoint)
->setCredentials($username, $password);
$apiClient = ApiClient::configure($configurator);
try {
// Get the currently logged-in User; the "me" ID is a special one, as documented on Mattermost.org APIs.
$user = $apiClient->users()->getUserById('me');
var_dump($user->getUsername());
php
use Pnz\MattermostClient\Model\Team;
$teamData = (new Team\TeamBuilder())
->setDisplayName('Team 01')
->setName('team-01')
->setType(Team\Team::TEAM_INVITE_ONLY)
->build();
$team = $apiClient->teams()->createTeam($teamData);
php
use Pnz\MattermostClient\Model\Post;
$post = $apiClient->posts()->getPost('zhcapisftibyjnf54gixg3hdew');
$postData = (new Post\PostBuilder())
->setMessage('I can `format` the _text_ of a *message*, including [links](www.mattermost.com)')
->setIsPinned(true)
->build(Post\PostBuilder::BUILD_FOR_PATCH);
$post = $apiClient->posts()->patchPost($post->getId(), $postData);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.