person
My Account

AdValify SDK & Examples

Ad Quality Control APIs

See if your ads comply with your ad specification. Fully customizable and automated.


SDK & Examples

Find AdValify's SDKs in 5 common programming languages here below. Build a proof of concept in less than an hour. Show your custom-built ad validation module to your colleagues, saving huge amounts of time.

PHP
JavaScript
Ruby
Node.js
Python
class AdValifySDK{
    private $apiKey;
    private $baseUrl;

    public function __construct($apiKey, $baseUrl) {
        $this->apiKey = $apiKey;
        $this->baseUrl = $baseUrl;
    }

    public function sendRequest($endpoint, $data = []) {
        // Set up cURL options
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $this->baseUrl . $endpoint);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_ENCODING , "");
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
        curl_setopt($ch, CURLOPT_HTTPHEADER, [
            'Content-Type: application/json',
            'X-ApiKey: ' . $this->apiKey,
        ]);

        // Execute the request
        $response = curl_exec($ch);

        // Check for cURL errors
        if (curl_errno($ch)) {
            throw new Exception('cURL Error: ' . curl_error($ch));
        }

        // Close cURL session
        curl_close($ch);

        // Return the API response (you may want to add error handling here)
        return $response;
    }
}

// Example usage:
$apiKey = 'YOUR_API_KEY';
$baseUrl = 'https://{your_name}.api.advaify.io';
$api = new AdValifySDK($apiKey, $baseUrl);

$endpoint = '/v3/someEndpoint';
$data = ['data' => base64_encode('BINARY_DATA_OR_AD_TAG_HERE')];

try {
    $response = $api->sendRequest($endpoint, $data);
    echo "API Response: " . $response;
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}