acquire_activation_code ( $gateway_url )

Fetches the activation code for a gateway using its public URL.

Access

public

Parameters

Parameter

Type

Required

Description

$gateway_url

string

Required

The public URL to a gateway.

Returns

Type

Description

string
boolean

The activation key for the gateway, or false if it could not be determined.

Source

Method defined in services/storagegateway.class.php | Toggle source view (23 lines) | View on GitHub

public function acquire_activation_code($gateway_url)
{
    // Send a request to the gateway's URL
    $request = new RequestCore($gateway_url);
    $request->ssl_verification = false;
    $request->set_curlopts(array(CURLOPT_FOLLOWLOCATION => false));
    $response = $request->send_request(true);

    // Parse the query string from the URL in the location header to get the activation key
    if (isset($response->header['location']))
    {
        $url = $response->header['location'];
        $query = parse_url($url, PHP_URL_QUERY);
        parse_str($query, $params);

        if (isset($params['activationKey']))
        {
            return $params['activationKey'];
        }
    }

    return false;
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback