updivision/matrix-php-sdk

How to use this?

Closed this issue · 2 comments

I can install this, but do you have any code samples?

How do I register user?

How do I login?

Thanks

Disclaimer: not affiliated with the package author

@AndreFabris looks like this package is still very much work in progress, and you can't do much atm. However, here's how to get started:

<?php

$username = 'myuser';
$password = '';

$u = Matrix::session();
$u->login($username, $password);
/*
=> [
        "access_token" => <some access token>,
        "home_server" => "matrix.mydomain.com",
        "user_id" => "@myuser:matrix.mydomain.com",
        "device_id" => "LWYGRFMNKJ",
    ]
*/

You can get this info at any time by calling $u->user() or session('updivision_matrix_data');

// Get the currently logged in user:
$up = Matrix::user();
$up->getProfile();
/*
=> [
      "displayname" => "That's my name",
    ]
*/
$up->setDisplayName('Some other name');
$up->getProfile();
/*
=> [
      "displayname" => "Some other name",
    ]
*/


Seems like from this object you can also register a user, however I haven't tried it myself

$up->register('anotheruser', 'somepassword');

This all works managed to register and login users