添加互动推广页(待废弃)
复制代码
<?php
require_once __DIR__ . '/../../../vendor/autoload.php'; // change path as needed
use TencentAds\TencentAds;
use TencentAds\Exception\TencentAdsResponseException;
use TencentAds\Exception\TencentAdsSDKException;
/*****
* 本文件提供了一个创建试玩素材(Playable page)的简单示例
*/
class AddPlayablePages
{
public static $tads;
public static $ACCESS_TOKEN = 'YOUR ACCESS TOKEN';
public static $ACCOUNT_ID = 'YOUR ACCOUNT ID';
public static $MATERIAL_FILE = 'YOUR MATERIAL ZIP FILE PATH';
public function init()
{
$tads = TencentAds::init([
'access_token' => static::$ACCESS_TOKEN,
'is_debug' => true,
]);
$tads->useSandbox(); // 默认访问沙箱环境,如访问正式环境,请切换为$tads->useProduction()
static::$tads = $tads;
return $tads;
}
public function main()
{
try {
/* @var TencentAds $tads */
$tads = static::$tads;
$playablePageName = 'SDK' . uniqid();
$response = $tads->playablePages()
->add([
'account_id' => static::$ACCOUNT_ID,
'playable_page_name' => $playablePageName,
'material_file' => static::$MATERIAL_FILE,
]);
$materialId = $response->getPlayablePageMaterialId();
return $materialId;
} catch (TencentAdsResponseException $e) {
// When Api returns an error
echo 'Tencent ads returned an error: ' . $e->getMessage() . PHP_EOL;
throw $e;
} catch (TencentAdsSDKException $e) {
// When validation fails or other local issues
echo 'Tencent ads SDK returned an error: ' . $e->getMessage() . PHP_EOL;
throw $e;
} catch (Exception $e) {
echo 'Other exception: ' . $e->getMessage() . PHP_EOL;
throw $e;
}
}
}
if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
try {
$example = new AddPlayablePages();
$example->init();
$example->main();
} catch (\Exception $e) {
exit(-1);
}
}
问题仍未解决?
请前往腾讯广告反馈中心在线提交问题,我们的人工客服将为你服务