From bc80b2a917f2f5f3aefd60ad429f6f40de139d60 Mon Sep 17 00:00:00 2001 From: filesite Date: Sat, 26 Apr 2025 05:46:39 +0800 Subject: [PATCH] add postback method --- conf/app.php | 1 + themes/tajian/controller/SiteController.php | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/conf/app.php b/conf/app.php index 53b8986..a1a7b05 100644 --- a/conf/app.php +++ b/conf/app.php @@ -216,6 +216,7 @@ $configs = array( //广告跟踪回调接口 "postbackApi" => "", + "postbackMethod" => "GET", "postbackParaMap" => array( "clickid" => 'gclid', ), diff --git a/themes/tajian/controller/SiteController.php b/themes/tajian/controller/SiteController.php index bb8b486..c463443 100644 --- a/themes/tajian/controller/SiteController.php +++ b/themes/tajian/controller/SiteController.php @@ -69,15 +69,19 @@ Class SiteController extends Controller { } //把广告参数追加到回调API网址中 - /* - foreach($adParaDataFromCookie as $key => $val) { - $postbackApi .= "&{$key}=" . urlencode($val); - } - */ - - //GET方式请求回调API $timeout = 10; - return $this->request($postbackApi, null, $timeout); + $postbackMethod = !empty(FSC::$app['config']['ad_tracker']['postbackMethod']) ? FSC::$app['config']['ad_tracker']['postbackMethod'] : 'GET'; + if ($postbackMethod == 'GET') { + foreach($adParaDataFromCookie as $key => $val) { + $postbackApi .= "&{$key}=" . urlencode($val); + } + + //GET方式请求回调API + return $this->request($postbackApi, null, $timeout); + }else { + //POST方式请求回调API + return $this->request($postbackApi, $adParaDataFromCookie, $timeout); + } } //增加cookie跟踪同意/不同意选择,确保用户知道cookie跟踪了哪些数据