PHP code example of elvanto / api-php

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

    

elvanto / api-php example snippets




$elvanto = new Elvanto_API();

$authorize_url = $elvanto->authorize_url(
	'Client ID for your application',
  'Redirect URI for your application',
  'The permission level your application 



$elvanto = new Elvanto_API();

$result = $elvanto->exchange_token(
  'Client ID for your application',
  'Client Secret for your application',
  'Redirect URI for your application',
  'A unique code for your user' // Get the code parameter from the query string.
);

$access_token = $result->access_token;
$expires_in = $result->expires_in;
$refresh_token = $result->refresh_token;
// Save $access_token, $expires_in and $refresh_token.



$auth_details = array(
	'access_token' => 'your access token',
	'refresh_token' => 'your refresh token'
);
$elvanto = new Elvanto_API($auth_details);

$results = $elvanto->call('people/getAll');
var_dump($results);



$auth_details = array(
	'access_token' => 'your access token',
	'refresh_token' => 'your refresh token'
);
$elvanto = new Elvanto_API($auth_details);

$results = $elvanto->call('people/getAll');
if (isset($results->error)) {
	// If you receive '121: Expired OAuth Token', refresh the access token.
	if ($results->error->code == 121) {
		list($new_access_token, $new_expires_in, $new_refresh_token) =
		  $elvanto->refresh_token();
		// Save $new_access_token, $new_expires_in, and $new_refresh_token.
	}
	// Make the call again.
	$results = $elvanto->call('people/getAll');
}
var_dump($results);



$auth_details = array('api_key' => 'your API Key');
$elvanto = new Elvanto_API($auth_details);

$results = $elvanto->call('people/getAll');
var_dump($results);

$results = $elvanto->('people/edit', array('id'=>'XXXXXXX', 'fields'=>array('email'=>'[email protected]')));