toneflix-code / adf-ly-laravel
A laravel package that wraps around Adf.ly API library.
2.0.0
2022-05-22 10:05 UTC
Requires
- php: ^7.4|^8.0
- illuminate/support: ~5.8.0|^6.0|^7.0|^8.0|^9.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
README
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 code@toneflix.com.ng instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.