Skip to content

Affiliate Networks API wrapper to provide common interface for affiliate networks program API

License

Notifications You must be signed in to change notification settings

padosoft/laravel-affiliate-network

Repository files navigation

Affiliate Networks API wrapper to provide common interface for affiliate networks publish API like Zanoz, Tradedoubler, Commission Junction etc...

Latest Version on Packagist Software License Build Status Quality Score Total Downloads SensioLabsInsight

The goal of this Laravel package is to wrap the Publisher Network Affiliate API like Zanox, Tradedoubler, Commission Junction etc.. and provide simple methods to get deals and sales report and return a common interface for your use.

##Overview

Common methods are:

  • getDeals : get the network deals.
  • getSales : get the network sales.
  • getStats : get the network deals stats.
  • getMerchants : get the network merchants.
  • checkLogin : check if logged in network.
  • login : login in into network.
  • getTrackingParameter : get network tracking params.
  • loadAvailableNetworks : get all available network.
  • hasNetwork : check if network are available.
  • addNetwork : add a network class that implements Network interface.

##Requires

  • php: >=7.0.0
  • illuminate/support
  • padosoft/support

Installation

You can install the package via composer:

$ composer require padosoft/laravel-affiliate-network

You must install this service provider.

// config/app.php
'provider' => [
    ...
    Padosoft\AffiliateNetwork\AffiliateNetworkServiceProvider::class,
    ...
];

You don't need to register the command in app/Console/Kernel.php, because it provides by AffiliateNetworkServiceProvider register() method.

You can publish the config file of this package with this command:

php artisan vendor:publish --provider="Padosoft\AffiliateNetwork\AffiliateNetworkServiceProvider"

The following config file will be published in config/laravel-affiliate-network.php

return array(
    'zanox' => array(
        'username' => env(
            'ZANOX_USERNAME',
            'padosoft'
        ),
        'password' => env(
            'ZANOX_PASSWORD',
            ''
        )
    ),
    'tradedoubler' => array(
        'username' => env(
            'TRADEDOUBLER_USERNAME',
            'padosoft'
        ),
        'password' => env(
            'TRADEDOUBLER_PASSWORD',
            ''
        )
    ),
    'commissionjunction' => array(
        'username' => env(
            'COMMISSIONJUNCTION_USERNAME',
            'padosoft'
        ),
        'password' => env(
            'COMMISSIONJUNCTION_PASSWORD',
            ''
        )
    ),
);

In your app config folder you can copy from src/config/.env.example the settings for yours .env file used in laravel-affiliate-network.php. If you use mathiasgrimm/laravel-env-validator in src/config folder you'll find an example for validate the env settings.

Networks Supported

  • CommissionJunction
  • Effiliation
  • Netaffiliation
  • Publicideas.com
  • TradeDoubler
  • Zanox
  • WebGains

Usage

Create new php file, add composer autoload and start using functions.

<?php

require "vendor/autoload.php";
//if not in laravel need to define this functions
if (!function_exists('public_path')){
    function public_path(){
        return dirname(__FILE__);
    }
}
$objNetworkManager= new NetworkManager();
$objNetworkManager->login('Zanox',$_ENV['ZANOX_USERNAME'], $_ENV['ZANOX_PASSWORD']);
$isLogged = $objNetworkManager->checkLogin('Zanox');
if ($isLogged){
    echo '<h1>Deals</h1>';
    $arrDeals = $objNetworkManager->getDeals('Zanox');
    echo '<pre>';
    var_dump($arrDeals);
    echo '</pre>';
}

In Laravel:

$networkManager=app(NetworkManager::class);

$dateFrom=new DateTime();
$dateTo= new DateTime();

//if you want to specify specific Merchant:
$arrMerchantID = array(
    array('cid' => '9716', 'name' => 'Zalando IT')
);
$networkManager->login('Zanox',$_ENV['ZANOX_USERNAME'], $_ENV['ZANOX_PASSWORD']);
$isLogged = $networkManager->checkLogin('Zanox');
if ($isLogged){
    echo '<h1>Transactions</h1>';
    $transactions = $networkManager->getSales('Zanox',$dateFrom,$dateTo,$arrMerchantID);
    echo '<h1>Deals</h1>';
    $arrDeals = $networkManager->getDeals('Zanox');
    echo '<pre>';
    var_dump($arrDeals);
    echo '</pre>';
}

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email instead of using the issue tracker.

Credits

About Padosoft

Padosoft (https://www.padosoft.com) is a software house based in Florence, Italy. Specialized in E-commerce and web sites.

License

The MIT License (MIT). Please see License File for more information.