You are here

function AkamaiCacheControl::clear_url in Akamai 6

Same name and namespace in other branches
  1. 8 akamai.class.inc \AkamaiCacheControl::clear_url()
  2. 8.2 akamai.class.inc \AkamaiCacheControl::clear_url()
  3. 6.2 akamai.class.inc \AkamaiCacheControl::clear_url()
  4. 7.3 akamai.class.inc \AkamaiCacheControl::clear_url()
  5. 7 akamai.class.inc \AkamaiCacheControl::clear_url()
  6. 7.2 akamai.class.inc \AkamaiCacheControl::clear_url()

Clears the provided URLs from the Akamai Content Cache.

Parameters

$paths: A path (or array of paths) to clear from Akamai

Return value

An array with 2 keys: success: TRUE or FALSE indicating cache clearing success message: Blank if successful, the error message if not successful.

File

./akamai.class.inc, line 47
akamai.class.inc Akamai is a registered trademark of Akamai Technologies, Inc. This class is an abstraction around the Akamai Cache Control API.

Class

AkamaiCacheControl
@file akamai.class.inc Akamai is a registered trademark of Akamai Technologies, Inc. This class is an abstraction around the Akamai Cache Control API.

Code

function clear_url($paths) {

  // Grab params
  extract($this->parameters);

  // make paths an array
  if (!is_array($paths)) {
    $url = array(
      $paths,
    );
  }

  // prepend base path to paths to make URIs
  $uris = array();
  foreach ($paths as $path) {
    $path = rtrim(preg_match("/^\\//", $path) ? $path : "/{$path}");
    array_push($uris, $basepath . $path);
  }
  $opt = array(
    "action={$action}",
    "domain={$domain}",
    "type={$type}",
  );
  if (!empty($email) && $email != AKAMAI_EMAIL_DISABLE) {
    $opt[] = "email-notification={$email}";
  }

  // create soap object
  try {
    $ccuapi = new SoapClient($soap_wsdl, array(
      'trace' => 1,
      'features' => SOAP_USE_XSI_ARRAY_TYPE,
    ));

    // call web service
    $response = $ccuapi
      ->purgeRequest($name, $pwd, $network, $opt, $uris);
    $is_success = $response->resultCode < 300;
    $message = $response->resultCode . ": " . $response->resultMsg;
    if (!$is_success) {
      throw new Exception($message);
    }
    foreach ($uris as $uri) {
      watchdog('Akamai', t("Akamai %action of %uri: %message"), array(
        '%uri' => $uri,
        '%action' => $action,
        '%message' => $message,
      ), WATCHDOG_NOTICE);
    }
  } catch (Exception $e) {
    watchdog('Akamai', t("Error Clearing Akamai Cache: %msg"), array(
      '%msg' => $e
        ->getMessage(),
    ));
    throw $e;
  }
  return $message;
}