1. Go to this page and download the library: Download jakuborava/scaleo-io-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/ */
jakuborava / scaleo-io-client example snippets
use JakubOrava\ScaleoIoClient\ScaleoIoClient;
$client = new ScaleoIoClient();
use JakubOrava\ScaleoIoClient\ScaleoIoClient;
$client = new ScaleoIoClient(
apiKey: 'your_api_key_here',
baseUrl: 'https://your-domain.scaletrk.com'
);
// Use environment variables as defaults, but override API key
$client = new ScaleoIoClient(
apiKey: 'different-api-key',
baseUrl: null // Will use SCALEO_BASE_URL from environment
);
use JakubOrava\ScaleoIoClient\ScaleoIoClient;
// Using environment variables
$client = new ScaleoIoClient();
// OR using direct configuration
$client = new ScaleoIoClient(
apiKey: 'your_api_key_here',
baseUrl: 'https://your-domain.scaletrk.com'
);
use JakubOrava\ScaleoIoClient\Requests\NetworkSummaryRequest;
use Carbon\Carbon;
// Get network summary for last 7 days
$summary = $client->affiliate()->dashboard()->networkSummary(
NetworkSummaryRequest::create()
->preset('last_7_days')
);
foreach ($summary as $metric) {
echo $metric->label . ': ' . $metric->total . PHP_EOL;
}
// List offer requests
$requests = $client->affiliate()->offerRequests()->list();
// List pending requests
$pending = $client->affiliate()->offerRequests()->pending();
// Create new request
$response = $client->affiliate()->offerRequests()->create([
'offer_id' => 123,
'message' => 'I would like to promote this offer',
]);
use JakubOrava\ScaleoIoClient\Requests\StatisticsReportRequest;
use Carbon\Carbon;
$report = $client->affiliate()->reports()->statistics()->list(
StatisticsReportRequest::create()
->rangeFrom(Carbon::now()->subDays(7))
->rangeTo(Carbon::now())
->columns(['offer_id', 'clicks', 'conversions', 'revenue'])
->breakdowns(['day'])
->page(1)
->perPage(50)
);
foreach ($report->items as $row) {
$stats = $row->statistics;
echo "Date: {$row->day_timestamp}" . PHP_EOL;
echo "Clicks: {$stats->clicks}" . PHP_EOL;
echo "Conversions: {$stats->conversions}" . PHP_EOL;
echo "Revenue: {$stats->revenue}" . PHP_EOL;
}
// Get available columns and breakdowns
$columns = $client->affiliate()->reports()->statistics()->options();
$breakdowns = $client->affiliate()->reports()->statistics()->breakdowns();
use JakubOrava\ScaleoIoClient\Requests\InvoicesListRequest;
// List invoices
$invoices = $client->affiliate()->billing()->invoices()->list(
InvoicesListRequest::create()->status('paid')
);
// Get specific invoice
$invoice = $client->affiliate()->billing()->invoices()->get(123);
// Download invoice PDF
$pdfPath = $client->affiliate()->billing()->invoices()->downloadPdf(123);
use JakubOrava\ScaleoIoClient\Requests\BaseRequest;
// Get countries with default settings
$countries = $client->common()->countries()->list();
foreach ($countries->results as $country) {
echo "{$country->id}: {$country->title}" . PHP_EOL;
// Example: CZ: Czech Republic
}
echo "Total countries: {$countries->count}" . PHP_EOL;
// Get countries with custom pagination
$countries = $client->common()->countries()->list(
(new BaseRequest)->page(2)->perPage(50)
);
use JakubOrava\ScaleoIoClient\Requests\BaseRequest;
// Get tags with default settings
$tags = $client->common()->tags()->list();
foreach ($tags->results as $tag) {
echo "{$tag->id}: {$tag->title}" . PHP_EOL;
// Example: 1: Exclusive
}
echo "Total tags: {$tags->count}" . PHP_EOL;
// Get tags with custom pagination
$tags = $client->common()->tags()->list(
(new BaseRequest)->page(1)->perPage(100)
);
use JakubOrava\ScaleoIoClient\Requests\BaseRequest;
// Get goal types with default settings
$goalTypes = $client->common()->goalTypes()->list();
foreach ($goalTypes->results as $goalType) {
echo "{$goalType->id}: {$goalType->title}" . PHP_EOL;
// Example: sale: Sale
}
echo "Total goal types: {$goalTypes->count}" . PHP_EOL;
// Get goal types with custom pagination
$goalTypes = $client->common()->goalTypes()->list(
(new BaseRequest)->page(1)->perPage(20)
);
use JakubOrava\ScaleoIoClient\Exceptions\AuthenticationException;
use JakubOrava\ScaleoIoClient\Exceptions\ValidationException;
use JakubOrava\ScaleoIoClient\Exceptions\ApiErrorException;
use JakubOrava\ScaleoIoClient\Exceptions\UnexpectedResponseException;
try {
$offers = $client->affiliate()->offers()->list();
} catch (AuthenticationException $e) {
// Handle authentication errors (401)
} catch (ValidationException $e) {
// Handle validation errors (422)
print_r($e->getErrors());
} catch (ApiErrorException $e) {
// Handle other API errors
echo "Error ({$e->getStatusCode()}): " . $e->getMessage();
} catch (UnexpectedResponseException $e) {
// Handle unexpected response format
}