PHP code example of keestash / php-sdk

1. Go to this page and download the library: Download keestash/php-sdk 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/ */

    

keestash / php-sdk example snippets


class ApiCredentialsProvider implements \Keestash\Sdk\Login\Entity\ApiCredentialsInterface {

    public function getApiUrl(): string
    {
        return 'your-keestash.server/api.php';
    }

    public function getUserToken(): ?string
    {
        return <userToken>;
    }

    public function getUserHash(): ?string
    {
        return <userHash>;
    }
}

$keestashClient = new \Keestash\Sdk\Client\KeestashClient(
    new GuzzleHttp\Client(),
    new ApiCredentialsProvider()
);

$login = new \Keestash\Sdk\Login\Login($keestashClient);
$data = $login->login(<username>, <password>);
var_dump($data);



// create credential
$c = new \Keestash\Sdk\PasswordManager\Entity\Credential(
    'test-password',
    'theusername',
    'topsecret',
    'root',
    'https://keestash.com'
);

$credential = new \Keestash\Sdk\PasswordManager\Credential\Credential($keestashClient);
$credential->create($c);

// create folder
$folder = new \Keestash\Sdk\PasswordManager\Folder\Folder($keestashClient);
$folder->create(new \Keestash\Sdk\PasswordManager\Entity\Folder('test-folder', 'root'));