/** * This returns adspaces for a Zanox user. */ function get_zanox_adspaces() { $option_name = 'dfrapi_zanox_adspaces'; $adspaces = get_transient($option_name); if (false === $adspaces || empty($adspaces)) { $zanox_keys = dfrapi_get_zanox_keys(); if (!$zanox_keys) { return array('zanox_error' => 'missing_keys'); } else { $client = new Dfr_ZanoxAPIClient($zanox_keys['connection_key'], $zanox_keys['secret_key']); $adspaces = $client->adspaces(); if ($client->error()) { return array('zanox_error' => $client->error()); } else { set_transient($option_name, $adspaces, HOUR_IN_SECONDS); } } } dfrapi_update_transient_whitelist($option_name); return $adspaces; }
/** * Returns a Zanox zmid value. */ function dfrapi_api_get_zanox_zmid($merchant_id, $adspace_id) { $option_name = 'zmid_' . $merchant_id . '_' . $adspace_id; $zanox = get_transient($option_name); if ($zanox === FALSE || empty($zanox)) { $api = dfrapi_api(dfrapi_get_transport_method()); try { $zanox_keys = dfrapi_get_zanox_keys(); $zanox = $api->getZanoxMerchantIds($merchant_id, $adspace_id, $zanox_keys['connection_key']); // If $zanox is empty, that means this user is not approved by this merchant. if (empty($zanox)) { $zanox = 'dfrapi_unapproved_zanox_merchant'; } } catch (Exception $err) { return dfrapi_api_error($err); } set_transient($option_name, $zanox, WEEK_IN_SECONDS); } dfrapi_update_transient_whitelist($option_name); return $zanox; }