toneflix-code/adf-ly-laravel

一个封装了Adf.ly API库的laravel包。

2.0.0 2022-05-22 10:05 UTC

This package is auto-updated.

Last update: 2024-09-22 15:11:10 UTC


README

Latest Version on Packagist Total Downloads

Laravel8|9 License

这个库是一个简单的laravel包,封装了Adf.ly API实现。

请参考Adf.ly API文档以获取详细的API使用描述。

要求

安装

您可以通过composer安装此包

composer require toneflix-code/adf-ly-laravel

服务提供者 & 门面(在Laravel 5.5+中可选)

在您的config/app.php文件中注册提供者和门面。

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

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

配置(可选)

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

API密钥

要开始使用此库,您需要配置您的API密钥在您的.env文件中,使用以下变量

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

用法

缩短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);

参数

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);

引用者GET

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

国家GET

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

公告GET

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

发布者引用统计GET

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

广告商引用统计GET

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

提款交易GET

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

提款GET

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

提款请求GET

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

提款请求DELETE

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

发布者统计GET

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

用户资料GET

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

广告商活动GET

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

广告商图形GET

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

广告商活动部分GET

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

认证POST

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

账户发布者引用

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

账户广告商引用

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

账户popad引用

$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

变更日志

请参阅变更日志获取更多信息。

贡献

请参阅贡献指南获取详细信息。

安全

如果您发现任何安全相关的问题,请通过电子邮件code@toneflix.com.ng联系,而不是使用问题跟踪器。

鸣谢

许可证

MIT许可证(MIT)。请参阅许可证文件获取更多信息。