getRequest('statistics')->result; foreach ($api_response as $i) { if (!isset($i->program->name)) continue; $tracking_url = $this->tracking_url($i->program->id); $output[] = array( 'name' => trim($i->program->name), 'category' => '-', 'tracking_url' => $tracking_url, 'network' => 'Adrecord', ); } return $output; } /** * Connect with service API and * return an array of transactions. * * @string: name * @int: transaction * @date: click_date * @date: event_date * @int: commission * @string: currency * @string: network * @return array */ public function transactions() { $output = array(); $api_response = $this->getRequest('transactions', array( 'start' => $this->from_date, 'stop' => $this->to_date, )); if (!isset($api_response) OR !isset($api_response->result)) return $output; foreach ($api_response->result as $i) { if (!isset($i->program->name) OR !isset($i->commissionName) OR !isset($i->type) OR !isset($i->click) OR !isset($i->changes[0]->date) OR !isset($i->commission)) continue; $output[] = array( 'name' => $i->program->name, 'transaction' => $i->commissionName . ' - ' . $i->type, 'click_date' => $this->dateToString($i->click), 'event_date' => $this->dateToString($i->changes[0]->date), 'commission' => $i->commission / 100, 'currency' => 'SEK', 'network' => 'Adrecord', ); } return $output; } /** * Options * Create admin menu options */ public function Options() { if (!$this->isConfigured()) return false; global $ymas; $ymas->admin_settings_advanced_tab->createOption( array( 'name' => $this->name, 'type' => 'heading', 'toggle' => true, )); $ymas->admin_settings_advanced_tab->createOption( array( 'name' => __('Clean links', 'ymas'), 'id' => $this->slug . '_enabled_cleanlinks', 'type' => 'checkbox', 'default' => true, 'desc' => __('Enable clean links', 'ymas') . '

' . __('Clean links is a technique to link to an advertiser with "regular links",
example directly to http://example.com instead of http://click.adrecord.com/?p=19&c=235.', 'ymas') . '
' . __('Read more','ymas') . '

', )); $ymas->admin_settings_advanced_tab->createOption( array( 'type' => 'save', 'use_reset' => false, )); } /* * WP Footer * Calls on wp hook wp_footer */ public function wp_footer() { if (!$this->isConfigured()) return; if (!$this->isEnabledOption('cleanlinks')) return; $channel_id = $this->channelID; ?> api_token; $url = 'https://api.adrecord.com/v1/' . $command . '?apikey=' . $api_token; if (isset($params['start']) AND isset($params['stop'])) $url .= "&start=" . $params['start'] . "&stop=" . $params['stop']; $handle = curl_init(); curl_setopt($handle, CURLOPT_URL, $url); curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, true); $data = curl_exec($handle); if ($data === false) { $info = curl_getinfo($handle); curl_close($handle); die('error occurred during curl exec. Additional info: ' . var_export($info)); } curl_close($handle); return json_decode($data); } /** * Tracking URL * Generate Adrecorc tracking url from program id and channel id */ public function tracking_url( $program_id ) { global $ymas; $channel_id = $ymas->titan->getOption( $this->slug . '_channel_id'); return "http://click.adrecord.com?c={$channel_id}&p={$program_id}"; } }