1. Go to this page and download the library: Download devster/guzzle-wsse-plugin 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/ */
devster / guzzle-wsse-plugin example snippets
use GuzzleHttp\Client;
use Devster\GuzzleHttp\Subscriber\WsseAuth;
// Create a Guzzle client
$client new Client(['base_url' => 'http://example.com']);
// and add it the plugin
(new WsseAuth('username', 'pass****'))->attach($client);
// Or
$client->getEmitter()->attach(new WsseAuth('username', '********'));
// Now the plugin will add the correct WSSE headers to your guzzle request
$response = $client->get('/data')->send();
use GuzzleHttp\Client;
use GuzzleHttp\Message\RequestInterface;
use Devster\GuzzleHttp\Subscriber\WsseAuth;
$client = new Client;
$plugin = new WsseAuth('username', 'pass****');
$plugin
->attach($client)
->setNonce(function (RequestInterface $request) {
return uniqid('my_nonce', true);
})
->setDigest(function ($nonce, $createdAt, $password) {
return $nonce.$createdAt.$password;
})
->setDateFormat('Y-m-d') // PHP format. Default: c (ISO 8601)
// Process a behavior (like hashing) on the password before it pass to the digest generator
->setPasswordProcessor(function ($password) {
return sha1($password);
})
;
shell
# Install Composer
curl -sS https://getcomposer.org/installer | php
# Add the plugin as a dependency
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.