· 9 years ago · Jan 26, 2017, 11:38 PM
1<?php
2
3require_once('client/ApiClient.php');
4
5/**
6 * API Calls for Affilinet webservice
7 * Username and password cookie
8 */
9if (isset($_COOKIE['Drupal_visitor_affiliate_overview_affilinet_username_active'])) {
10 define("AFFILINET_USERNAME", $_COOKIE['Drupal_visitor_affiliate_overview_affilinet_username_active']);
11}
12else {
13 define("AFFILINET_USERNAME", variable_get('affilinet_username')); // Publisher-ID for Affilinet
14}
15define("AFFILINET_PASSWORD", variable_get('affilinet_password')); // Publisher webservices password for Affilinet
16
17/**
18 * API Calls for Belboon webservices
19 * Username and password cookie
20 */
21if (isset($_COOKIE['Drupal_visitor_affiliate_overview_belboon_username_active'])) {
22 define("BELBOON_USERNAME", $_COOKIE ['Drupal_visitor_affiliate_overview_belboon_username_active']);
23}
24else {
25 define("BELBOON_USERNAME", variable_get('belboon_username')); // Publisher username for Belboon
26}
27define("BELBOON_PASSWORD", variable_get('belboon_password')); // Publisher webservices password for Belboon
28
29/**
30 * API Calls for Zanox webservices
31 * Connectid and Secretkey cookie
32 */
33if (isset($_COOKIE['Drupal_visitor_affiliate_overview_zanox_connectid_active'])) {
34 define("ZANOX_CONNECTID", $_COOKIE ['Drupal_visitor_affiliate_overview_zanox_connectid_active']);
35}
36else {
37 define("ZANOX_CONNECTID", variable_get('zanox_connectid')); // Connectid for Zanox webservices
38}
39define("ZANOX_SECRETKEY", variable_get('zanox_secretkey')); // Secretkey for Zanox webservices
40
41/**
42 * API Calls for Tradetracker webservices
43 * Client ID and passphrase cookie
44 */
45if (isset($_COOKIE['Drupal_visitor_affiliate_overview_tradetracker_id_active'])) {
46 define("TRADETRACKER_ID", $_COOKIE ['Drupal_visitor_affiliate_overview_tradetracker_id_active']);
47}
48else {
49 define("TRADETRACKER_ID", variable_get('tradetracker_id')); // ID for Tradetracker webservices
50}
51define("TRADETRACKER_PASSPHRASE", variable_get('tradetracker_passphrase')); // Passphrase for Tradetracker webservices
52
53/**
54 * API
55 */
56define("WSDL_LOGON", "https://api.affili.net/V2.0/Logon.svc?wsdl"); // Affilinet webservices authentication token
57define("WSDL_ACCOUNT", "https://api.affili.net/V2.0/AccountService.svc?wsdl"); // Affilinet webservices statistics
58define("WSDL_SERVER", "http://api.belboon.com/?wsdl"); // Belboon webservices statistics
59define("WSDL_ZANOX", "https://api.zanox.com/wsdl/2011-03-01"); // Zanox webservices
60define("WSDL_TRADETRACKER", "http://ws.tradetracker.com/soap/affiliate?wsdl"); //Tradetracker webservices
61
62function _affiliate_overview_affilinet_stats() {
63 if (variable_get('affilinet_checkbox', TRUE)) {
64 /*
65 * Send request to Affilinet logon service for authentication token
66 */
67 try {
68 $soapLogon = new SoapClient(WSDL_LOGON);
69 $token = $soapLogon->Logon(array(
70 'Username' => AFFILINET_USERNAME,
71 'Password' => AFFILINET_PASSWORD,
72 'WebServiceType' => 'Publisher'
73 ));
74
75 /**
76 * Send request to Affilinet publisher statistics webservices
77 */
78 $soapRequest = new SoapClient(WSDL_ACCOUNT);
79 $response = $soapRequest->GetPublisherSummary($token);
80 return $response;
81 }
82 catch (Exception $e) {
83 echo 'Error: ', $e->getMessage(), "\n";
84 drupal_exit();
85 }
86
87 }
88}
89
90function _affiliate_overview_belboon_stats() {
91 if (variable_get('belboon_checkbox', TRUE)) {
92 $config = array(
93 'login' => BELBOON_USERNAME,
94 'password' => BELBOON_PASSWORD,
95 'trace' => true
96 );
97
98 $client = new SoapClient(WSDL_SERVER, $config);
99 $result = $client->getAccountInfo();
100 return $result;
101
102 }
103}
104
105function _affiliate_overview_zanox_stats() {
106 if (variable_get('zanox_checkbox', TRUE)) {
107
108 $api = ApiClient::factory(PROTOCOL_SOAP, VERSION_DEFAULT);
109
110 $connectId = variable_get('zanox_connectid');
111 $secretKey = variable_get('zanox_secretkey');
112
113 $api->setConnectId($connectId);
114 $api->setSecretKey($secretKey);
115
116 $programId = '400';
117 ;
118
119 $soap = $api->getPrograms($programId);
120
121 print "<pre>";
122 print_r($soap);
123 }
124}
125
126function _affiliate_overview_tradetracker_stats() {
127 if (variable_get('tradetracker_checkox', TRUE)) {
128 $client = new SoapClient(WSDL_TRADETRACKER, array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP));
129 $client->authenticate(TRADETRACKER_ID, TRADETRACKER_PASSPHRASE);
130
131 $affiliateSiteID = 251122;
132
133 $DateFrom = strtotime('first day of ' . date('F Y'));
134 $DateTo = strtotime("today");
135
136 $response = $client->getReportReference($affiliateSiteID, $DateFrom, $DateTo);
137
138 print "<pre>";
139 print_r($response);
140 }
141}