atgames/ads-php

Atgames 数字服务 PHP 库

1.0.5 2016-05-17 04:35 UTC

This package is not auto-updated.

Last update: 2024-09-23 12:33:48 UTC


README

要求

PHP 5.3.3 及以上版本。

Composer

您可以通过 Composer 安装这些绑定。运行以下命令

composer require atgames/ads-php

要使用这些绑定,请使用 Composer 的 自动加载

require_once('vendor/autoload.php');

手动安装

如果您不希望使用 Composer,可以下载 [最新版本](https://gitlab.direct2drive.com/atgames/ads-php)。然后,为了使用这些绑定,请包含 init.php 文件。

require_once('/path/to/ads-php/init.php');

入门指南

简单用法如下

\Ads\Ads::setApiKey('OTEwMDA6a1I2UkFTelJhUS1lcWNZSkw1blE=');
$data = \Ads\Product::all();
echo $data;

文档

请参阅 https://api.atgames.net/docs/api 获取最新文档。

自定义请求超时

要修改请求超时(连接或总超时,单位为秒),您需要告知 API 客户端使用非默认的 CurlClient。您将在那个 CurlClient 中设置超时。

// set up your tweaked Curl client
$curl = new \Ads\HttpClient\CurlClient();
$curl->setTimeout(10); // default is \Ads\HttpClient\CurlClient::DEFAULT_TIMEOUT
$curl->setConnectTimeout(5); // default is \Ads\HttpClient\CurlClient::DEFAULT_CONNECT_TIMEOUT

echo $curl->getTimeout(); // 10
echo $curl->getConnectTimeout(); // 5

// tell Ads to use the tweaked client
\Ads\ApiRequestor::setHttpClient($curl);

// use the Ads API client as you normally would

开发

安装依赖

composer install

测试

如上所述安装依赖(这将解决 PHPUnit),然后您可以运行测试套件

./vendor/bin/phpunit

或运行单个测试文件

./vendor/bin/phpunit tests/UtilTest.php