gnello / php-mattermost-driver

The PHP Driver to interact with the Mattermost Web Service API.
Apache License 2.0
79 stars 27 forks source link

With https:// in the beginning 500 error and without nothing happens #34

Closed e-stonia closed 4 years ago

e-stonia commented 4 years ago

Hey, when I have 'url' => 'https://cloud.mydomain.com', then I get "HTTP ERROR 500" and without https:// I get "Everything is ok.NULL". Here's my code:

<?php
require 'vendor/autoload.php';
use \Gnello\Mattermost\Driver;

 $container = new \Pimple\Container([
     'driver' => [
         'url' => 'cloud.mydomain.com',
         'token' => 'token',
     ],
     'guzzle' => [
         //put here any options for Guzzle
     ]
 ]);

 $driver = new Driver($container);
 $result = $driver->authenticate();

 //Add a new user
$result = $driver->getUserModel()->createUser([
    'email'    => 'atest@test.com', 
    'username' => 'atest100', 
    'password' => 'Asdc1523!Asdc1523!'
]);

$result = $driver->getChannelModel()->createChannel([
    'name'         => 'channel111',
    'display_name' => 'Channel111',
    'type'         => 'O',
]);

 if ($result->getStatusCode() == 200) {
    echo "Everything is ok.";
    var_dump(json_decode($result->getBody()));
} else {
    echo "HTTP ERROR " . $result->getStatusCode();
}
?>
gnello commented 4 years ago

Hi, it's not necessary to pass the scheme in the url, as it is specified by default by the Driver (you can see that here), otherwise you're actually sending any requests to https://https://cloud.mydomain.com.

I'm sorry I did not make that clear into the Readme, thanks for pointing this out.

I've updated the Readme (see here).

e-stonia commented 4 years ago

Thanks. Do you have any idea why I get then "Everything is ok.NULL" and actually the user isn't created?

gnello commented 4 years ago

Hi, looking at your example the "Everything is ok.NULL" is the result output of the createChannel call. Are you also getting "Everything is ok.NULL" with the createUser output?

kasparpalgi commented 4 years ago

Are you also getting "Everything is ok.NULL" with the createUser output?

Yes.

gnello commented 4 years ago

Hi, I tried your code in a 5.28.1 mattermost server (using this to get a clean installation) and it worked, what version of Mattermost are you using? Any clue in your mattermost server logs files?