PHP code example of webthink / guzzle-jwt
1. Go to this page and download the library: Download webthink/guzzle-jwt 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/ */
webthink / guzzle-jwt example snippets
php
class MyAuthenticator implements AuthenticatorInterface
{
public function authenticate($username, $password)
{
// code.. and return a TokenInterface.
}
}
php
// Your handler stack
$stack = HandlerStack::create();
// Add middleware
$stack->append(new Middleware($myAuthenticator));
$httpClient = new Client([
'handler' => $stack,
'jwt' => [
'username' => 'username',
'password' => 'password',
],
]);
$response = $httClient->get('/my_api_that_