PHP code example of meta-tech / pws-client
1. Go to this page and download the library: Download meta-tech/pws-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/ */
meta-tech / pws-client example snippets
Symfony\Component\Yaml\Yaml;
use MetaTech\PwsAuth\Authenticator;
use MetaTech\Ws\Client;
$config = Yaml::parse(file_get_contents(__dir__ . '/config/pwsauth.yml'));
$authenticator = new Authenticator($config);
$config = Yaml::parse(file_get_contents(__dir__ . '/config/pwsclient.yml'));
$client = new Client($config, $authenticator);
// on instanciation the client init this calls :
// $client->check();
// enventually $client->call() (depending on previous response);
// get example
$response = $client->get('/ws/person/222');
if ($response->done) {
// do stuff
}
// post example
$response = $client->post('/ws/person/222/update', [ 'firstname' => 'toto']);
if ($response->done) {
// do stuff
}
// to close and destroy session on serverside :
// $client->logout();