$data['account_id'], 'level' => 'REPORT_LEVEL_ADVERTISER', 'date_range' => [ 'start_date' => $data['start_date'], 'end_date' => $data['end_date'], ], 'order_by' => [ [ 'sort_field' => 'date', 'sort_type' => 'ASCENDING' ] ], 'group_by' => [ 'date' ], 'fields' => [ 'view_count','view_user_count','date','account_id','cost', 'valid_click_count', 'follow_count','scan_follow_count','scan_follow_user_count', 'conversions_count', 'deep_conversions_count' ], 'page' => 1, 'page_size' => 100 ]; do { $parameters['access_token'] = $access_token; $parameters['timestamp'] = time(); $parameters['nonce'] = md5(time().rand(10000,99999)); foreach ($parameters as $key => $value) { if (!is_string($value)) { $parameters[$key] = json_encode($value); } } $request_url = $url . '?' . http_build_query($parameters); $res = HttpService::httpGet($request_url); // 记录日志 Log::logInfo('获取日报数据API:' . $interface, [ 'url' => $request_url, 'version' => $version, 'params' => $parameters, 'response' => $res, ], 'ReportsOpenApi'); $resArr = json_decode($res, true); if (!$resArr) { $resArr = [ 'code' => 666666, 'message' => '请求失败(自定义)' ]; } if($resArr['code'] != 0) { sleep(1); } } while(($resArr['code'] != 0) && (--$retry > 0)); if ($resArr['code'] == 0) { return self::returnSuccess($resArr['data']); } else { return self::returnFail([], $resArr['message']); } } /** * 日报获取 */ public static function mergeFundTypeFundsGet($accountId, $retry = 5) { $version = self::getAccountVersion($accountId); $interface = 'merge_fund_type_funds/get'; $url = 'https://api.e.qq.com/' . $version . '/' . $interface; $access_token = TencentAdAuth::getAccessToken($accountId); if (empty($access_token)) return false; do { $parameters['timestamp'] = time(); $parameters['access_token'] = $access_token; $parameters['nonce'] = md5(time().rand(10000,99999)); $parameters['account_id'] = $accountId; foreach ($parameters as $key => $value) { if (!is_string($value)) { $parameters[$key] = json_encode($value); } } $request_url = $url . '?' . http_build_query($parameters); $res = HttpService::httpGet($request_url); // 记录日志 Log::logInfo('获取资金账户数据API:' . $interface, [ 'url' => $request_url, 'version' => $version, 'params' => $parameters, 'response' => $res, ], 'ReportsOpenApi'); $resArr = json_decode($res, true); if (!$resArr) { $resArr = [ 'code' => 666666, 'message' => '请求失败(自定义)' ]; } if($resArr['code'] != 0) { sleep(10); } } while(($resArr['code'] != 0) && (--$retry > 0)); if ($resArr['code'] == 0) { return self::returnSuccess($resArr['data']); } else { return self::returnFail([], $resArr['message']); } } public static function getAccountVersion($accountId) { $accountList = [ 39369591,39369590,39584550,38560767,38560766,39369558,38560787,38560786,38560804,39584519,39584517,39369557, 39369541,39369564,39369567,39369568,38560752,38560751,38560993,38560899,38560971,39369562,38560824,38560750, 38560749,38560748,38560747,38560820,38560825,38560473,38560973,39369562,38560971,38560780,38560782,38560785, 38560765,38560764,38560763,38560762,38560761,38560760,38560759,38560755,38560754,38560753,38560795,39584565, 39584568,39584570,39584571,39584572,39369536,39369537,39369538,39369539,39369540,38561071,39369542,39369543, 39369544,38560797,38560798,38560799,38560805,38560808,38560811,38560793,38560818,39584517,39369556,39369553, 35881409,38560792,38560784,39584519,39369723,39369585,35881506,39369701,39369702,39584552,38560801,38560802, 38560803,38560999,39369553,39369556,38560801,38560802,38560803,38560999,39369553,39369556,42094657,42094655, 42094652,42094651 ]; $version = 'v1.3'; if(date('Y-m-d H:i:s') >= '2024-04-20 00:00:00' || in_array($accountId, $accountList)) { $version = 'v3.0'; } return 'v3.0'; } }