Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
Amazon S3 - List BucketsDemonstrates how to send a GET request to the Amazon S3 service to list buckets.
LOCAL loHttp LOCAL lnSuccess LOCAL lcCurDateTime LOCAL lcStrToSign LOCAL loCrypt LOCAL lcAWSAccessKeyId LOCAL lcAWSSecretAccessKey LOCAL lcSignature LOCAL lcAuthValue LOCAL lcXmlResponse loHttp = CreateObject('Chilkat.Http') lnSuccess = loHttp.UnlockComponent("Anything for 30-day trial.") IF (lnSuccess <> 1) THEN * Unlock failed. =MESSAGEBOX(loHttp.LastErrorText) QUIT ENDIF * The HTTP component now includes a method to generate * the current date/time in RFC 2616 compliant format. * Note: The GenTimeStamp method is available as a pre-release (as of 18-June-2008). * It will become available in the next new version dated after * 18-June-2008. lcCurDateTime = loHttp.GenTimeStamp() =MESSAGEBOX(lcCurDateTime) * The GET operation on the Service endpoint (s3.amazonaws.com) returns a list of all of the buckets owned by the authenticated sender of the request. lcStrToSign = "GET" + [CHR(10) + [CHR(10) + [CHR(10) + lcCurDateTime + [CHR(10) + "/" loCrypt = CreateObject('Chilkat.Crypt2') lnSuccess = loCrypt.UnlockComponent("Anything for 30-day trial.") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loCrypt.LastErrorText) QUIT ENDIF * We want SHA1 for the HMAC hash algorithm: loCrypt.HashAlgorithm = "sha1" * These must be changed for your account: lcAWSAccessKeyId = "0PN5J17HBGZHT7JJ3X82" lcAWSSecretAccessKey = "uV3F3YluFJax1cknvbcGwgjvx4QpvB+leU8dUj2o" * Set the HMAC secret key: loCrypt.SetHmacKeyString(lcAWSSecretAccessKey) * By setting the charset = "utf-8", the string will be converted * to utf-8 (internal to the Chilkat component) prior to signing: loCrypt.Charset = "utf-8" * Indicate that Base64 output is desired: loCrypt.EncodingMode = "base64" lcSignature = loCrypt.HmacStringENC(lcStrToSign) lcAuthValue = "AWS " + lcAWSAccessKeyId + ":" + lcSignature loHttp.SetRequestHeader("Authorization",lcAuthValue) loHttp.SetRequestHeader("Date",lcCurDateTime) lcXmlResponse = loHttp.QuickGetStr("http://s3.amazonaws.com/") IF (lcXmlResponse = NULL ) THEN * Failed. Show the last request header, response header, * and response body. ? loHttp.LastHeader ? "---" ? loHttp.LastResponseHeader ? "---" ? loHttp.LastErrorText ELSE * Success, show the XML response: ? lcXmlResponse ENDIF |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.
Mail Component · .NET Email Component · ASP Mail Component · XML Parser