Code Monkey home page Code Monkey logo

adf-ly-laravel's Introduction

Adf.ly Laravel API wrapper

Latest Version on Packagist Total Downloads

Laravel8|9 License

This library is a simple laravel package that wraps around Adf.ly API implementations.

Please refere to Adf.ly API Documentation for detailed api use description.

Requirements

Installation

You can install the package via composer:

composer require toneflix-code/adf-ly-laravel

Service Provider & Facade (Optional on Laravel 5.5+)

Register provider and facade on your config/app.php file.

'providers' => [
    ...,
    ToneflixCode\AdfLy\AdfLyServiceProvider::class,
]

'aliases' => [
    ...,
    'AdfLy' => ToneflixCode\AdfLy\AdfLyFacade::class,
]

Configuration (Optional)

php artisan vendor:publish --provider="ToneflixCode\AdfLy\AdfLyServiceProvider"

API Keys

To start using this library you are required to configure your API keys in your .env file with these variables

ADFLY_SECRET_KEY=your-adf.ly secret key
ADFLY_PUBLIC_KEY=your-adf.ly public key
ADFLY_USER_ID=your-adf.ly user ID

Usage

Shorten Url

use ToneflixCode\AdfLy\AdfLy;
$adfly = new AdfLy;
$res = $adfly->shorten(array('http://stackoverflow.com/users'), 'q.gs');

$shortenedUrl1 = $res['data'][0];
$hash1 = substr($shortenedUrl1['short_url'],strrpos($shortenedUrl1['short_url'],'/')+1);
echo 'First URL shortened (' . $hash1 . '): ' . print_r($res);

$res = $adfly->shorten(array('http://www.reddit.com'), 'q.gs');
$shortenedUrl2 = $res['data'][0];
$hash2 = substr($shortenedUrl2['short_url'],strrpos($shortenedUrl2['short_url'],'/')+1);
echo 'Another URL shortened (' . $hash2 . '): ' . print_r($res);

$res = $adfly->shorten(array('www.youtube.com'), 'q.gs', 'banner');
$shortenedUrl3 = $res['data'][0];
echo 'Another URL shortened: ' . print_r($res);

$res = $adfly->shorten(array('http://www.len10.com/videos/'), 'q.gs', 'int', 13);
$shortenedUrl4 = $res['data'][0];
echo 'Another URL shortened: ' . print_r($res);

Parameters

function shorten(
    array $urls,
    $domain = false,
    $advertType = false,
    $groupId = false,
    $title = false,
    $customName = false
)

Expand.

print_r($adfly->expand(array($shortenedUrl3['short_url'],$shortenedUrl4['short_url']),array($hash1,$hash2)));

LISTING

// List Urls
$urlList = $adfly->getUrls();
print_r($urlList);

// Update Url
$adfly->updateUrl($shortenedUrl1['id'], 'http://modifiedurlaaaa.cat', "int", "The  updated URL", 13, false, false);
print_r($adfly->expand(array(),array($hash1)));

foreach($urlList['data'] as $url){
    $adfly->deleteUrl($url['id']);
}

//List Urls again
$urlList = $adfly->getUrls();
print_r($urlList);

GROUPS

$g = $adfly->createGroup('API Group');
print_r($g);

$g = $adfly->getGroups(1);
print_r($g);

REFERRERS GET

$res = $adfly->getReferrers();
print_r($res);

COUNTRIES GET

$res = $adfly->getCountries();
print_r($res);

ANNOUNCEMENTS GET

$res = $adfly->getAnnouncements();
print_r($res);

publisherReferralStats GET

$res = $adfly->getPublisherReferrals();
print_r($res);

advertiserReferralStats GET

$res = $adfly->getAdvertiserReferrals();
print_r($res,1);

withdrawalTransactions GET

$res = $adfly->getWithdrawalTransactions();
print_r($res,1);

withdraw GET

$res = $adfly->getWithdraw();
print_r($res,1);

withdraw request GET

$res = $adfly->withdrawRequestInitiate();
print_r($res,1);

withdraw request DELETE

$res = $adfly->withdrawRequestCancel();
print_r($res,1);

publisher Stats GET

$res = $adfly->getPublisherStats();
print_r($res,1);

user Profile GET

$res = $adfly->getProfile();
print_r($res,1);

advertiser Campaigns GET

$res = $adfly->getAdvertiserCampaigns();
print_r($res,1);

advertiser Graph GET

$res = $adfly->getAdvertiserGraph(null,156);
print_r($res,1);

advertisers Campaign parts GET

$res = $adfly->getAdvertiserCampaignParts(739026);
print_r($res,1);

auth POST

$res = $adfly->auth('1', '2');
print_r($res,1);

account publisher referrals

$res = $adfly->getAccountPubReferrals('', '', 1);
print_r($res);

account advertiser referrals

$res = $adfly->getAccountAdvReferrals('', '', 1);
print_r($res);

account popad referrals

$res = $adfly->getAccountPopReferrals('', '', 1);
print_r($res);

account total referrals

$res = $adfly->getAccountTotalReferrals();
print_r($res);

Domains

$res = $adfly->getDomains();
print_r($res);

update account details

$res = $adfly->updateAccountDetails([]);
print_r($res);

update account password

$res = $adfly->updatePassword('oldpassword', 'newpassword', 'newpassword');
print_r($res);

get account countries

$res = $adfly->getAccountCountries();
print_r($res);

get account details

$res = $adfly->getAccountDetails();
print_r($res);

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

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

Credits

License

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

adf-ly-laravel's People

Contributors

3m1n3nc3 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.