Example #1
0
 /**
  * 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;
 }
Example #2
0
/**
 * This retuns merchant or merchants' information by merchant_id or
 * an array of merchant IDs.
 */
function dfrapi_api_get_merchants_by_id($ids, $includeEmpty = FALSE)
{
    $name = false;
    if (is_array($ids)) {
        sort($ids, SORT_NUMERIC);
        $id_string = implode(",", $ids);
        $name = md5($id_string);
    } elseif ($ids != '') {
        $name = trim($ids);
    }
    if (!$name) {
        return;
    }
    $name = substr($name, 0, 20);
    $option_name = 'dfrapi_merchants_byid_' . $name;
    $merchants = get_transient($option_name);
    if (false === $merchants || empty($merchants)) {
        $api = dfrapi_api(dfrapi_get_transport_method());
        try {
            $merchants = $api->getMerchantsById($ids, $includeEmpty);
            dfrapi_api_update_status($api);
        } catch (Exception $err) {
            return dfrapi_api_error($err);
        }
        set_transient($option_name, $merchants, DAY_IN_SECONDS);
    }
    dfrapi_update_transient_whitelist($option_name);
    return $merchants;
}