PHP code example of melonsmasher / ethos-php

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

    

melonsmasher / ethos-php example snippets




elonSmasher\EthosPHP\EthosClient;
use MelonSmasher\EthosPHP\Foundation\PersonsClient;

// Your API Key / Refresh Token
$secret = 'YourApiKey/RefreshToken';
// Create an authenticated Ethos session
$ethos = EthosClient::createSession($secret);
// Create a new Persons client using your Ethos session
$personsClient = new PersonsClient($ethos);
// Read the first page of persons
$page1 = $personsClient->read()->data();
// Move to the next page
$personsClient->nextPage();
// Read the second page
$page2 = $personsClient->read()->data();
// Set the page to the fourth page
$personsClient->setPage(4);
// Read the 4th page to an array
$page4 = $personsClient->read()->toArray();
// Move 1 page back to the 3rd
$personsClient->backPage();
// Read the 3rd page to a JSON string
$page3 = $personsClient->read()->toJson();
// Skip to the 6th page
$personsClient->nextPage(4);
// Read the 7th page
$page7 = $personsClient->read()->data();
// Skip back to the 5th page
$personsClient->backPage(2);
// Read the 5th page
$page5 = $personsClient->read()->data();



elonSmasher\EthosPHP\EthosClient;
use MelonSmasher\EthosPHP\Foundation\PersonsClient;

// Your API Key / Refresh Token
$secret = 'YourApiKey/RefreshToken';
// Create an authenticated Ethos session
$ethos = EthosClient::createSession($secret);
// Create a new Persons client using your Ethos session
$personsClient = new PersonsClient($ethos);
// Send a request with the `criteria` parameter filtering for a person with a colleaguePersonId of 9000001.
$data = $personsClient->read([
    'criteria' => '{"credentials":[{"type":"colleaguePersonId","value":"9000001"}]}'
])->data();      
bash
composer