Esempio n. 1
0
 public function testGetDailyReportStats()
 {
     $accounts = $this->ads->getAllAccounts();
     $account = $accounts[array_rand($accounts)];
     $campaigns = $this->ads->getAdSetsFromAccount($account->id);
     $campaign_ids = \ebussola\facebook\ads\adset\AdSetHelper::extractIds($campaigns);
     $data_columns = array('campaign_id', 'campaign_name', 'impressions', 'clicks', 'social_impressions', 'social_clicks', 'unique_impressions', 'unique_clicks', 'unique_social_impressions', 'unique_social_clicks', 'actions', 'spend');
     $filters = array(\ebussola\facebook\ads\ReportStatsHelper::createFilter('campaign_id', 'in', $campaign_ids));
     $results = $this->ads->getDailyReportStats($account->id, $data_columns, $filters, new DateTime('today'), new DateTime('today +15 days'));
     foreach ($results as $result) {
         $this->assertTrue(in_array($result->campaign_id, $campaign_ids));
     }
 }
Esempio n. 2
0
 /**
  * @param string    $account_id
  * @param array     $data_columns
  * @param array     $filters
  * @param \DateTime $start_date
  * @param \DateTime $end_date
  *
  * @see ReportStatsHelper::createFilter
  *
  * @return array
  */
 public function getDailyReportStats($account_id, array $data_columns, array $filters, \DateTime $start_date, \DateTime $end_date)
 {
     $account_id = $this->fixAccountId($account_id);
     $this->fixTimezone($account_id, $start_date);
     $this->fixTimezone($account_id, $end_date);
     $end_date = clone $end_date;
     $end_date->add(new \DateInterval('P1D'));
     $time_ranges = ReportStatsHelper::createDailyTimeRange($start_date, $end_date);
     return $this->getSyncReportStats($account_id, $data_columns, $filters, $time_ranges);
 }
Esempio n. 3
0
 /**
  * @param           $campaign_ids
  * @param \DateTime $date_start
  * @param \DateTime $date_end
  * @param           $stats_data
  *
  * @return array
  */
 private function _createDailyCampaignStats($campaign_ids, \DateTime $date_start, \DateTime $date_end)
 {
     $data_columns = $this->getCampaignFields();
     $filters = array(ReportStatsHelper::createFilter('campaign_id', 'in', $campaign_ids));
     $stats = $this->ads->getDailyReportStats($this->account_id, $data_columns, $filters, $date_start, $date_end);
     $stats_report = new CampaignStatsReport();
     foreach ($stats as $stats_data) {
         $stats = new \ebussola\ads\reports\facebook\campaignstats\CampaignStats($stats_data);
         $stats->refreshValues();
         $stats_report->addStats($stats);
     }
     return $stats_report;
 }