Google 애널리틱스 API (PHP 클라이언트 라이브러리 - 서버 간 서비스로 사용)를 여러 번 사용하면 빈 결과 집합이 반환됩니다. 이 같은 내 코드 조회 :Google 애널리틱스 API가 빈 결과를 반환하는 경우가 있음
public function getLeadDetails($view, $gauid, $lead_id,$refresh_token,$dates = [])
{
Log::info("*****************GA Service - GAUID: ".$gauid." **********************************");
$options['dimensions'] = implode(',',config('analytics.dimensions'));
$options['filters'] = "ga:eventAction==".$gauid;
$metrics = "ga:users";
$view = "ga:".$view;
$yesterday = date('Y-m-d',strtotime('yesterday'));
$tomorrow = date("Y-m-d",strtotime('tomorrow'));
if(count($dates)){
$yesterday = $dates['yesterday'];
$tomorrow = $dates['tomorrow'];
}
Log::info('[email protected](), Request Params: ?ids='.$view.'&start-date='.$yesterday.'&end-date='.$tomorrow.'&metrics='.$metrics.'&dimensions='.$options['dimensions'].'&filters='.$options['filters']);
try{
$this->client->setAccessType('offline');
$this->client->setAccessToken($refresh_token);
$this->client->setClientId(config('analytics.client_id'));
$this->client->setScopes([
\Google_Service_Analytics::ANALYTICS,
\Google_Service_Analytics::ANALYTICS_EDIT,
]);
$analytics = new \Google_Service_Analytics($this->client);
$data = $analytics->data_ga->get($view,$yesterday,$tomorrow,$metrics,$options);
if($data['totalResults'] && $data['totalResults'] > 0){
Log::info('Inside [email protected] has totalResults');
$rtn = [];
$i = 0;
foreach ($data['rows'] as $row) {
$rtn['uacid'] = $gauid;
$rtn['user_type'] = $row[0];
$rtn['device_category'] = $row[1];
$rtn['source'] = $row[2];
$rtn['medium'] = $row[3];
$rtn['campaign'] = $row[4];
$rtn['ad_group'] = $row[5];
$rtn['path'] = $row[6];
$i++;
}
Log::info('Inside [email protected] lead '.$lead_id.' should be update');
return $this->insertLeadDetails($rtn , $lead_id);
}
Log::info('GA_Service::getLeadDetails() returned empty results for lead: '.$lead_id);
if(!count($dates)){
$this->throwException('empty results for lead: '.$lead_id.' in GA_Service::getLeadDetails()',275);
return false;
}
return 'empty results for lead: '.$lead_id.' in GA_Service::getLeadDetails()';
}catch (\Google_Service_Exception $e){
Log::info('Google service exception from GA_Service::getLeadDetails() - '. $e->getErrors()[0]['message']);
$this->throwException($e->getErrors()[0]['message'], 335);
}
return false;
}
결과 (5 회) 비어 다시 5 분마다 경우이 기능 화재 여전히 몇 가지 결과를 벗어났습니다.
어떤 아이디어가 있고 어떻게 해결할 수 있습니까?
감사의 인사,이 부분이 아마도 누락되었습니다. – benjah