|
3 年之前 | |
---|---|---|
.. | ||
bin | 3 年之前 | |
config | 3 年之前 | |
examples | 3 年之前 | |
public | 3 年之前 | |
src | 3 年之前 | |
CHANGELOG.md | 3 年之前 | |
CONTRIBUTING.md | 3 年之前 | |
LICENSE.md | 3 年之前 | |
README.md | 3 年之前 | |
composer.json | 3 年之前 | |
git_push.sh | 3 年之前 |
腾讯广告 Marketing API(以下简称API) SDK 提供了Token获取、请求封装、响应解释等功能,以本地化方式轻松完成API的调用和结果的获取,旨在帮助开发者快速搭建投放管理系统。 未来还会基于常用的广告投放场景,提供场景化的接口组合及调用封装。
{
"require": {
"tencent-ad/marketing-api-php-sdk" : "*"
}
}
composer install --no-dev
SDK同时支持数组参数和语义化调用,推荐使用数组参数,方便后续升级扩展。本说明文档都使用数组参数调用的形式。/docs目录下的文档使用了语义化调用的方式。 SDK数组参数调用的方法名与API接口一一对应,如campaigns/get接口就对应$tads->campaigns()->get()方法
<?php
require_once __DIR__ . '/vendor/autoload.php'; // vendor 目录中的 autoload 文件
use TencentAds\TencentAds;
$tads = TencentAds::init([]);
$token = $tads->oauth()
->token([ // oauth/token接口即对应oauth()->token()方法
'client_id' => '{your client id}',
'client_secret' => '{your client secret}',
'grant_type' => 'authorization_code',
'authorization_code' => '{your authorization code}',
'redirect_uri' => '{your redirect uri}',
]);
echo "<pre>" . PHP_EOL;
print_r($token);
echo "</pre>" . PHP_EOL;
$tads->setAccessToken($token->getAccessToken());
<?php
require_once __DIR__ . '/vendor/autoload.php';
use TencentAds\TencentAds;
$tads = TencentAds::init([
'access_token' => '{access-token}',
])->useSandbox(); // 默认访问沙箱环境,如访问正式环境,请调用$tads->useProduction()
<?php
require_once __DIR__ . '/vendor/autoload.php';
use TencentAds\TencentAds;
use TencentAds\Exception\TencentAdsResponseException;
use TencentAds\Exception\TencentAdsSDKException;
$tads = TencentAds::init([
'access_token' => '{your access token}',
]);
try {
$filtering = [
[
'field' => 'promoted_object_type',
'operator' => 'EQUALS',
'values' => ['PROMOTED_OBJECT_TYPE_APP_IOS'],
],
];
$response = $tads
->campaigns()
->get([ // campaigns/get接口即对应campaigns()->get()方法
'account_id' => '{your account id}',
'filtering' => $filtering,
]);
echo "<pre>" . PHP_EOL;
print_r($response);
echo "</pre>" . PHP_EOL;
} catch (TencentAdsResponseException $e) {
// When Api returns an error
echo 'Tencent ads returned an error: ' . $e->getMessage();
exit;
} catch (TencentAdsSDKException $e) {
// When validation fails or other local issues
echo 'Tencent ads SDK returned an error: ' . $e->getMessage();
exit;
}
<?php
require_once __DIR__ . '/vendor/autoload.php';
use TencentAds\TencentAds;
$tads = TencentAds::init([
'access_token' => '{access-token}',
'is_debug' => true,
'debug_file' => '{your log path}', // 不指定,输出到 php://output
]);
<?php
require_once __DIR__ . '/vendor/autoload.php';
use TencentAds\TencentAds;
$tads = TencentAds::init([
'access_token' => '{access-token}',
'is_monitor' => false,
]);
<?php
require_once __DIR__ . '/vendor/autoload.php';
use TencentAds\TencentAds;
use TencentAds\Kernel\SerializerHandler;
$tads = TencentAds::init([
'access_token' => '{access-token}',
'is_monitor' => false,
]);
$tads->setSerializerType(SerializerHandler::SERIALIZER_TYPE_ARRAY);
如果您在使用SDK过程中有任何问题与建议,请随时登录开发者官网,点击右下角的"咨询"按钮,与我们的客服支持人员联系