搜索门店
复制代码
<?php
require_once __DIR__ . '/../../../vendor/autoload.php'; // change path as needed
use TencentAds\TencentAds;
use TencentAds\Exception\TencentAdsResponseException;
use TencentAds\Exception\TencentAdsSDKException;
/*****
* 本文件提供了一个搜索附近推门店(Local stores)的简单示例
*/
class GetLocalStoresSearchInfo
{
public static $tads;
public static $ACCESS_TOKEN = 'YOUR ACCESS TOKEN';
public static $ACCOUNT_ID = 'YOUR ACCOUNT ID';
public static $KEY_WORD = 'YOUR KEYWORD'; // 关键词
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;
$response = $tads->localStoresSearchInfo()
->get([
'account_id' => static::$ACCOUNT_ID,
'key_word' => static::$KEY_WORD,
]);
// 从返回里获得Local store信息
foreach ($response->getList() as $store) {
// echo $store . PHP_EOL;
}
return $response;
} 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 GetLocalStoresSearchInfo();
$example->init();
$example->main();
} catch (\Exception $e) {
exit(-1);
}
}
问题仍未解决?
请前往腾讯广告反馈中心在线提交问题,我们的人工客服将为你服务