Git Product home page Git Product logo

adstxtparser's Introduction

AdsTxtParser

PRs Welcome Build Status Latest Stable Version Latest Unstable Version License

Total Downloads Monthly Downloads Daily Downloads

A open source implentation in PHP of Ads.txt Specification Version 1.0.1 (OpenRTB working group)

Graph Ads.txt

Note: ADS = Authorized Digital Sellers DSP = Demand Side Platforms

WHAT IS ADS.TXT?

Ads.txt is an initiative by the Interactive Advertising Bureau to enable publishers to take control over who can sell their ad inventory.

Since 01 Nov 2017 Google is filtering traffic based on ads.txt

It is a simple logic of the textfile as mechanism to fight adfraud

Widely accepted and implemented by more and more publishers, ssp and dsp.

Can prevent advertisers from buying invalid traffic.

Check more info about it.

Donate

I am a freelancer Senior Backend Engineer working on my free time for develop this.

If you want pay me some beer or severals to appreciate the efforts:

paypal

Setup

Install with composer with only:

composer require shakaran/adstxtparser

TECHNICAL NOTES

Requires PHP 7.0+.

How to use

A quick use to instanciate and run over a domain is:

use AdsTxtParser\Parser;

$parser = new Parser();
$parser->readExternalFile('http://estaticos.elmundo.es');

Note: that you only have to pass as argument the domain.

After you already fetch the data in the Parser object, you can query about errors:

$errors = $parser->getErrors();

Or warnings:

$warnings = $parser->getWarnings();

Or get the variables defined:

$variables = $parser->getVariables();

Or get the fields defined:

$fields = $parser->getFields();

Or get the comments defined:

$comments = $parser->getComments();

Even more complex operations, as know the list of resellers:

$resellers = $parser->getResellers();

Or the list or directs:

$directs = $parser->getDirects();

A complex example using all the options could be:

try
        {
            // By default localhost
            $parser = new Parser();
            $parser->readExternalFile('http://estaticos.elmundo.es');

            // More examples to test:
            // https://elpais.com/ads.txt
            // https://www.elconfidencial.com/ads.txt
        }
        catch(AdsFileNotFound $e)
        {
            echo $e->getMessage();
        }

        $comments = $parser->getComments();
        // var_dump($comments);

        $errors = $parser->getErrors();
        //var_dump($errors);

        $warnings = $parser->getWarnings();
        // var_dump($warnings);

        $fields = $parser->getFields();
        // var_dump($fields);

        $variables = $parser->getVariables();
        //var_dump($variables);

        $resellers = $parser->getResellers();
        //var_dump(count($resellers));

        $directs = $parser->getDirects();
        //var_dump(count($directs));

Tests

Executing the tests:

Run a local webserver under Test directory:

cd Tests; sudo php -S localhost:80
vendor/phpunvendor/phpunit/phpunit/phpunit --configuration=Tests/phpunit.xml --include-path=Tests

License

AGPLv3 or later, see LICENSE file for more details.

adstxtparser's People

Contributors

shakaran avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ikeraslt

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.