$access_token, 'timestamp' => time(), 'nonce' => md5(uniqid('', true)) ]; $parameters = [ 'account_id' => $accountId, 'fields' => [ 'wechat_account_id', 'wechat_account_name', 'corporation_name' ], 'page' => 1, 'page_size' => 10, ]; $parameters = array_merge($common_parameters, $parameters); foreach ($parameters as $key => $value) { if (!is_string($value)) { $parameters[$key] = json_encode($value); } } $request_url = $url . '?' . http_build_query($parameters); do { $res = HttpService::httpGet($request_url); // 记录日志 Log::logInfo('获取公众号详情信息API:' . $interface, [ 'url' => $request_url, 'params' => $parameters, 'response' => $res, ], 'AdvertiserOpenApi'); $resArr = json_decode($res, true); if (!$resArr) { $resArr = [ 'code' => 666666, 'message' => '请求失败(自定义)' ]; } } while(($resArr['code'] != 0) && (--$retry > 0)); if ($resArr['code'] == 0) { return self::returnSuccess($resArr['data']); } else { return self::returnFail([], $resArr['message']); } } public static function getOrganizationAccount($accountId, $cursor, $retry = 0) { $interface = 'organization_account_relation/get'; $url = 'https://api.e.qq.com/v3.0/' . $interface; $accessToken = TencentAdAuth::getAccessToken($accountId); if (empty($accessToken)) { Log::logError('获取accessToken失败', ['account_id' => $accountId], 'getOrganizationAccount'); return false; } $parameters = array ( 'access_token' => $accessToken, 'timestamp' => time(), 'nonce' => md5(uniqid('', true)), 'pagination_mode' => 'PAGINATION_MODE_CURSOR', "cursor" => $cursor, "page_size" => 100 ); foreach ($parameters as $key => $value) { if (!is_string($value)) { $parameters[$key] = json_encode($value); } } $request_url = $url . '?' . http_build_query($parameters); $response = HttpService::httpGet($request_url); if(empty($response) && $retry < 5) { sleep(1); $retry++; return self::getOrganizationAccount($accountId, $cursor, $retry); } // 记录日志 Log::logInfo('获取业务单元下的投放账户:' . $interface, [ 'url' => $request_url, 'params' => $parameters, 'response' => $response, ], 'getOrganizationAccount'); return json_decode($response, true); } }