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.
You can install the package via composer:
composer require toneflix-code/adf-ly-laravel
Register provider and facade on your config/app.php
file.
'providers' => [
...,
ToneflixCode\AdfLy\AdfLyServiceProvider::class,
]
'aliases' => [
...,
'AdfLy' => ToneflixCode\AdfLy\AdfLyFacade::class,
]
php artisan vendor:publish --provider="ToneflixCode\AdfLy\AdfLyServiceProvider"
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
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);
function shorten(
array $urls,
$domain = false,
$advertType = false,
$groupId = false,
$title = false,
$customName = false
)
print_r($adfly->expand(array($shortenedUrl3['short_url'],$shortenedUrl4['short_url']),array($hash1,$hash2)));
// 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);
$g = $adfly->createGroup('API Group');
print_r($g);
$g = $adfly->getGroups(1);
print_r($g);
$res = $adfly->getReferrers();
print_r($res);
$res = $adfly->getCountries();
print_r($res);
$res = $adfly->getAnnouncements();
print_r($res);
$res = $adfly->getPublisherReferrals();
print_r($res);
$res = $adfly->getAdvertiserReferrals();
print_r($res,1);
$res = $adfly->getWithdrawalTransactions();
print_r($res,1);
$res = $adfly->getWithdraw();
print_r($res,1);
$res = $adfly->withdrawRequestInitiate();
print_r($res,1);
$res = $adfly->withdrawRequestCancel();
print_r($res,1);
$res = $adfly->getPublisherStats();
print_r($res,1);
$res = $adfly->getProfile();
print_r($res,1);
$res = $adfly->getAdvertiserCampaigns();
print_r($res,1);
$res = $adfly->getAdvertiserGraph(null,156);
print_r($res,1);
$res = $adfly->getAdvertiserCampaignParts(739026);
print_r($res,1);
$res = $adfly->auth('1', '2');
print_r($res,1);
$res = $adfly->getAccountPubReferrals('', '', 1);
print_r($res);
$res = $adfly->getAccountAdvReferrals('', '', 1);
print_r($res);
$res = $adfly->getAccountPopReferrals('', '', 1);
print_r($res);
$res = $adfly->getAccountTotalReferrals();
print_r($res);
$res = $adfly->getDomains();
print_r($res);
$res = $adfly->updateAccountDetails([]);
print_r($res);
$res = $adfly->updatePassword('oldpassword', 'newpassword', 'newpassword');
print_r($res);
$res = $adfly->getAccountCountries();
print_r($res);
$res = $adfly->getAccountDetails();
print_r($res);
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.