定制 admitad/api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

admitad/api

最新稳定版本:0.3.2

Composer 安装命令:

composer require admitad/api

包简介

Admitad api library

关键字:

README 文档

README

A PHP wrapper around the Admitad API

Install

Install http://getcomposer.org/ and run the following command:

php composer.phar require admitad/api dev-master

Examples

Request access token

  • By username / password
$api = new \Admitad\Api\Api()
$response = $api->authorizeByPassword($clientId, $clientPassword, $scope, $username, $password);
$result = $api->getArrayResultFromResponse($response); // or $response->getArrayResult();
  • OAuth2
// 1 step - get oauth authorization url
$api = new \Admitad\Api\Api();
$authorizeUrl = $api->getAuthorizeUrl($clientId, $redirectUri, $scope);
// redirect user to authorizeUrl


// 2 step - request access token by OAuth2 code returned from authorization url
$response = $api->requestAccessToken($clientId, $clientSecret, $code, $redirectUri);
$result = $api->getArrayResultFromResponse($response);
  • Signed Request (for applications on apps.admitad.com)
$api = new \Admitad\Api\Api();
$data = $api->parseSignedRequest($signedRequest, $clientSecret);
// this method throws Admitad\Api\Exception\InvalidSignedRequestException when $signedRequest is invalid

Refresh token

$response = $api->refreshToken($clientId, $clientSecret, $refreshToken);
$result = $api->getArrayResultFromResponse($response);

Methods

There are 2 common methods to communicate with api:

$api = new \Admitad\Api\Api($accessToken);

$api->get($path, $params);
$api->post($path, $params);

//for example
$response = $api->get('/advcampaigns/', array(
    'limit' => 20,
    'offset' => 0
));

$result = $api->getArrayResultFromResponse($response);

Paginated-result methods can be iterated in this way (instead of manually call methods with different offsets)

$iterator = $api->getIterator('/advcampaigns/', array(
    'order_by' => 'id'
));

foreach ($iterator as $campaign) {
    // do smth with campaign
}

统计信息

  • 总下载量: 195.91k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 36
  • 点击次数: 3
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 35
  • Watchers: 9
  • Forks: 34
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知