PHP code example of dant89 / ix-api-client

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

    

dant89 / ix-api-client example snippets


use Dant89\IXAPIClient\Client;

// Create base client
$client = new Client(IXAPI_URL);

// Get a bearer token from key / secret
$response = $client->getHttpClient(HttpClientType::AUTH)
    ->postAuthToken(IXAPI_KEY, IXAPI_SECRET);

// Check for valid response status
if ($response->getStatus() === 200) {
    $client->setBearerToken($response->getContent()['access_token']);
}

// Query for products
$response = $client->getHttpClient(HttpClientType::PRODUCT_OFFERINGS)
    ->get();

// Check for valid response and set the array of products
if ($response->getStatus() === 200) {
    $productOfferings = $response->getContent();
}

$singleItem = $client->getHttpClient(HttpClientType::CONTACTS)
    ->get('item-uuid')
    ->getContent();
    
$filteredItems = $client->getHttpClient(HttpClientType::CONTACTS)
    ->get(null, ['managing_account' => 'uuid-123'])
    ->getContent();

$response = $client->getHttpClient(HttpClientType::CONTACTS)
    ->post([
        'managing_account' => 'uuid-123',
        'consuming_account' => 'uuid-456',
        'name' => 'sample contact',
    ]);
    
$client->getHttpClient(HttpClientType::CONTACTS)
    ->patch('item-uuid', [
        'name' => 'renamed sample contact',
    ]);
    
$client->getHttpClient(HttpClientType::CONTACTS)
    ->delete('item-uuid');

// Query for connections timeseries data
$timeseries = $client->getHttpClient(HttpClientType::CONNECTIONS)
    ->getStatisticTimeseries('connection-123-uuid', '30d')
    ->getContent();