TarzanCore

Core functionality and default settings shared across classes.

Version

2008.12.10

Copyright

2006-2008 LifeNexus Digital, Inc., and contributors.

License

Simplified BSD Licensehttp://opensource.org/licenses/bsd-license.php

See Also

Tarzanhttp://tarzan-aws.com

Constants

TARZAN_NAME

Name of the software.

TARZAN_VERSION

Version of the software.

TARZAN_BUILD

Build ID of the software.

TARZAN_URL

URL to learn more about the software.

TARZAN_USERAGENT

User agent string used to identify Tarzan

Tarzan/2.0 (Amazon Web Services API; http://tarzan-aws.com) Build/20081210155146

DATE_AWS_RFC2616

Define the RFC 2616-compliant date format

DATE_AWS_ISO8601

Define the ISO-8601-compliant date format

DATE_AWS_MYSQL

Define the MySQL-compliant date format

HTTP_GET

HTTP method type: Get

HTTP_POST

HTTP method type: Post

HTTP_PUT

HTTP method type: Put

HTTP_DELETE

HTTP method type: Delete

HTTP_HEAD

HTTP method type: Head

TarzanCore

Container for all shared methods.  This is not intended to be instantiated directly, but is extended by the Amazon-specific classes.

Properties

key

The Amazon API Key.

secret_key

The Amazon API Secret Key.

account_id

The Amazon Account ID, sans hyphens.

assoc_id

The Amazon Associates ID.

util

Handle for the utility functions.

service

An identifier for the current AWS service.

api_version

The supported API version.

utilities_class

The default class to use for Utilities (defaults to TarzanUtilities).

request_class

The default class to use for HTTP Requests (defaults to TarzanHTTPRequest).

response_class

The default class to use for HTTP Responses (defaults to TarzanHTTPResponse).

adjust_offset

The number of seconds to adjust the request timestamp by (defaults to 0).

enable_ssl

Whether SSL/HTTPS should be enabled by default.

set_proxy

Sets the proxy to use for connecting.

Functions

autoloader()

public static function autoloader($class)

Automatically load classes that aren’t included.

Access

public static

Parameters

class_namestring (Required) The classname to load.

Returns

void

__construct()

public function __construct($key =  null,
$secret_key =  null,
$account_id =  null,
$assoc_id =  null)

The constructor

Access

public

Parameters

keystring (Optional) Your Amazon API Key.  If blank, it will look for the AWS_KEY constant.
secret_keystring (Optional) Your Amazon API Secret Key.  If blank, it will look for the AWS_SECRET_KEY constant.
account_idstring (Optional) Your Amazon account ID without the hyphens.  Required for EC2.  If blank, it will look for the AWS_ACCOUNT_ID constant.
assoc_idstring (Optional) Your Amazon Associates ID.  Required for AAWS.  If blank, it will look for the AWS_ASSOC_ID constant.

Returns

boolean FALSE if no valid values are set, otherwise true.

adjust_offset()

public function adjust_offset($seconds)

Allows you to adjust the current time, for occasions when your server is out of sync with Amazon’s servers.

Access

public

Parameters

secondsinteger (Required) The number of seconds to adjust the sent timestamp by.

Returns

void

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/tarzan/adjust_offset.phps

enable_ssl()

public function enable_ssl($enable =  true)

Enables all Amazon classes to use SSL (https) for enhanced security.  SSL is enabled by default starting with r198.

Access

public

Parameters

enableboolean (Optional) Whether to enable SSL or not.

Returns

void

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/tarzan/enable_ssl.phps

set_proxy()

public function set_proxy($proxy)

Set the proxy settings to use for connecting.

Access

public

Parameters

proxystring (Required) Accepts proxy credentials in the following format: proxy://user:pass@hostname:port

Returns

void

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/tarzan/set_proxy.phps

set_utilities_class()

function set_utilities_class($class =  'TarzanUtilities')

Set a custom class for this functionality.  Perfect for extending/overriding existing classes with new functionality.

Access

public

Parameters

classstring (Optional) The name of the new class to use for this functionality.  Defaults to the default class.

Returns

void

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/tarzan/set_utilities_class.phps

set_request_class()

function set_request_class($class =  'TarzanHTTPRequest')

Set a custom class for this functionality.  Perfect for extending/overriding existing classes with new functionality.

Access

public

Parameters

classstring (Optional) The name of the new class to use for this functionality.  Defaults to the default class.

Returns

void

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/tarzan/set_request_class.phps

set_response_class()

function set_response_class($class =  'TarzanHTTPResponse')

Set a custom class for this functionality.  Perfect for extending/overriding existing classes with new functionality.

Access

public

Parameters

classstring (Optional) The name of the new class to use for this functionality.  Defaults to the default class.

Returns

void

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/tarzan/set_response_class.phps

authenticate()

public function authenticate($action,  
$opt =  null,
$domain =  null,
$message =  null)

Default, shared method for authenticating a connection to AWS.  Overridden on a class-by-class basis as necessary.  This should not be used directly unless you’re writing custom methods for this class.

Access

public

Parameters

actionstring (Required) Indicates the action to perform.
optarray (Optional) Associative array of parameters for authenticating.  See the individual methods for allowed keys.
domainstring (Optional) The URL of the queue to perform the action on.
messagestring (Optional) This parameter is only used by the send_message() method.

Returns

TarzanHTTPResponse object

cache_response()

public function cache_response($method,  
$location,  
$expires,  
$params =  null)

Caches a TarzanHTTPResponse object using the preferred caching method.

Access

public

Parameters

methodstring (Required) The method of the current object that you want to execute and cache the response for.  If the method is not in the $this scope, pass in an array where the correct scope is in the [0] position and the method name is in the [1] position.
locationstring (Required) The location to store the cache object in.  This may vary by cache method.  See below.
expiresinteger (Required) The number of seconds until a cache object is considered stale.
paramsarray (Optional) An indexed array of parameters to pass to the aforementioned method, where array[0] represents the first parameter, array[1] is the second, etc.

Example values for $location

FileLocal file system paths such as ./cache (relative) or /tmp/cache/tarzan (absolute).  Location must be server-writable.
APCPass in ‘apc’ to use this lightweight cache.  You must have the APC extension installed.  http://php.net/apc
PDOA URL-style string (e.g. pdo.mysql://user:pass@localhost/tarzan_cache) or a standard DSN-style string (e.g. pdo.sqlite:/sqlite/tarzan_cache.db).  MUST be prefixed with ‘pdo.’.  See CachePDO and http://php.net/pdo for more details.

Returns

TarzanHTTPResponse object

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/tarzan/cache_response.phps