Giter VIP home page Giter VIP logo

ad-validator-php's Introduction

PHP Ad Validator Class: test Ad Tags, HTML5 Zip Ads and VAST Ads

This PHP uses the API from CreativeQA.io to analyze the ads. It returns an array of metrics, like:

  • CPU usage
  • Load size in bytes
  • Load speed in ms
  • Network requests
  • SSL-compatibility
  • Third-party cookies
  • Ad dimensions (width/height)
  • Plays video (boolean)
  • If blocked by adblock
  • ...and much more!

Ad formats

This PHP class supports the following ad formats:

  • Ad Tags
  • HTML5 Zip Ads
  • VAST Video Ads

Preparation

Request a free API key via https://www.creativeqa.io/html5-ad-validator - you'll get an API key and your endpoint emailed within minutes. Download the PHP class from this repository and paste your endpoint and API Key in the two variables at the top of the class.

Methods

$array = scanZip($filename);
$array = scanTag($tag);
$array = scanVAST($url);

Basic Examples

Scan an HTML5 Zip Ad

include('CreativeQA.php');
$CreativeQA = new CreativeQA();
$array = $CreativeQA->scanZip("/path/to/file.zip");
var_dump($array);

Scan an Ad Tag

include('CreativeQA.php');
$CreativeQA = new CreativeQA();
$array = $CreativeQA->scanTag("This is an ad tag...");
var_dump($array);

Scan a VAST tag

include('CreativeQA.php');
$CreativeQA = new CreativeQA();
$array = $CreativeQA->scanVAST("https://raw.githubusercontent.com/InteractiveAdvertisingBureau/VAST_Samples/master/VAST%203.0%20Samples/Inline_Companion_Tag-test.xml");
var_dump($array);

Some other examples

Ad servers like Google Ad Manager usually scan a creative to make sure it's SSL-compatible. To do so, use this example:

include('CreativeQA.php');
$CreativeQA = new CreativeQA();
$array = $CreativeQA->scanTag("This is an ad tag...");
$ssl_compatible = $array['ssl_compatible']; //boolean

To get a preview of an ad tag, use this example:

include('CreativeQA.php');
$CreativeQA = new CreativeQA();
$array = $CreativeQA->scanTag("This is an ad tag...");
$preview_image = file_get_contents($array['screenshot']['highres']['url']); //holds image in binary format

To create a backup ad for a HTML5 Zip Ad:

include('CreativeQA.php');
$CreativeQA = new CreativeQA();
$array = $CreativeQA->scanZip("/path/to/file.zip");
$backup_ad = file_get_contents($array['screenshot']['highres']['url']); //holds image in binary format

To check if a creative drops third-party cookies:

include('CreativeQA.php');
$CreativeQA = new CreativeQA();
$array = $CreativeQA->scanTag("This is an ad tag...");
$drops_cookies = (count($array['cookies'])>0); //boolean

To get the dimensions of an ad tag:

include('CreativeQA.php');
$CreativeQA = new CreativeQA();
$array = $CreativeQA->scanTag("This is an ad tag...");
$width = $array['dimensions']['width']; //int
$height = $array['dimensions']['height']; //int

To get the CPU usage of a HTML5 Zip Ad:

include('CreativeQA.php');
$CreativeQA = new CreativeQA();
$array = $CreativeQA->scanZip("/path/to/file.zip");
$cpu_usage = $array['cpu_usage']; //in milliseconds

To get the memory usage of a HTML5 Zip Ad:

include('CreativeQA.php');
$CreativeQA = new CreativeQA();
$array = $CreativeQA->scanZip("/path/to/file.zip");
$cpu_usage = $array['memory_usage']; //in bytes

To get the all network requests of an ad tag:

include('CreativeQA.php');
$CreativeQA = new CreativeQA();
$array = $CreativeQA->scanTag("This is an ad tag...");
$network = $array['network']; //an array with lots of interesting data

To check if an ad tag STILL uses document.write(), even though we're in the year 2021:

include('CreativeQA.php');
$CreativeQA = new CreativeQA();
$array = $CreativeQA->scanTag("This is an ad tag...");
$network = $array['uses_document_write']; //boolean

Full API Documentation

See here: https://www.creativeqa.io/api-docs

API Pricing

The API at CreativeQA.io can be used free of charge, even for commercial products. A Fair-Use-Policy applies.

Help & Support

If you need further help integrating these APIs in your platform, feel free to reach out:

https://www.creativeqa.io/contact

ad-validator-php's People

Contributors

creativeqa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.