Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Tcl Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(Tcl) SQS Receive Message

Retrieves one or more messages from an Amazon SQS queue, with a maximum limit of 10 messages, from the specified queue.

See SQS ReceiveMessage or detailed information.

Chilkat Tcl Extension Downloads

Chilkat Tcl Extension Downloads

load ./chilkat.dll

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

set rest [new_CkRest]

# Connect to the Amazon AWS REST server.
# such as https://sqs.us-west-2.amazonaws.com/
set bTls 1
set port 443
set bAutoReconnect 1
set success [CkRest_Connect $rest "sqs.us-west-2.amazonaws.com" $port $bTls $bAutoReconnect]

# Provide AWS credentials for the REST call.
set authAws [new_CkAuthAws]

CkAuthAws_put_AccessKey $authAws "AWS_ACCESS_KEY"
CkAuthAws_put_SecretKey $authAws "AWS_SECRET_KEY"
# the region should match our URL above..
CkAuthAws_put_Region $authAws "us-west-2"
CkAuthAws_put_ServiceName $authAws "sqs"

CkRest_SetAuthAws $rest $authAws

CkRest_AddQueryParam $rest "Action" "ReceiveMessage"
CkRest_AddQueryParam $rest "MaxNumberOfMessages" "5"
CkRest_AddQueryParam $rest "VisibilityTimeout" "15"
CkRest_AddQueryParam $rest "AttributeName" "All"
CkRest_AddQueryParam $rest "MessageAttributeName" "All"

# Use the actual path part of your SQS queue URL here:
set responseXml [CkRest_fullRequestNoBody $rest "GET" "/123456789123/chilkatTest"]
if {[CkRest_get_LastMethodSuccess $rest] != 1} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkAuthAws $authAws
    exit
}

# A successful response will have a status code equal to 200.
if {[CkRest_get_ResponseStatusCode $rest] != 200} then {
    puts "response status code = [CkRest_get_ResponseStatusCode $rest]"
    puts "response status text = [CkRest_responseStatusText $rest]"
    puts "response header: [CkRest_responseHeader $rest]"
    puts "response body: $responseXml"
    delete_CkRest $rest
    delete_CkAuthAws $authAws
    exit
}

# Examine the successful XML response.
set xml [new_CkXml]

CkXml_LoadXml $xml $responseXml
puts [CkXml_getXml $xml]
puts "----"

# A successful response looks like this:
# <?xml version="1.0" encoding="utf-8" ?>
# <ReceiveMessageResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/">
#     <ReceiveMessageResult>
#         <Message>
#             <Body>this is a test</Body>
#             <MD5OfBody>54b0c58c7ce9f2a8b551351102ee0938</MD5OfBody>
#             <ReceiptHandle>AQEBMyLof...UbKBTvHtEg==</ReceiptHandle>
#             <Attribute>
#                 <Name>SenderId</Name>
#                 <Value>957491831129</Value>
#             </Attribute>
#             <Attribute>
#                 <Name>ApproximateFirstReceiveTimestamp</Name>
#                 <Value>1475013283557</Value>
#             </Attribute>
#             <Attribute>
#                 <Name>ApproximateReceiveCount</Name>
#                 <Value>4</Value>
#             </Attribute>
#             <Attribute>
#                 <Name>SentTimestamp</Name>
#                 <Value>1475013283557</Value>
#             </Attribute>
#             <MessageId>52882c65-5e21-4450-9024-93a3b01e61d3</MessageId>
#             <MD5OfMessageAttributes>2ff68603f4239272bd03f543254ed040</MD5OfMessageAttributes>
#         </Message>
#     </ReceiveMessageResult>
#     <ResponseMetadata>
#         <RequestId>05ba5c92-80ee-5f87-be76-0cf67b7475d6</RequestId>
#     </ResponseMetadata>
# </ReceiveMessageResponse>

# Get some values from the XML:
puts "Body: [CkXml_chilkatPath $xml ReceiveMessageResult|Message|Body|*]"
puts "MessageId: [CkXml_chilkatPath $xml ReceiveMessageResult|Message|MessageId|*]"

set unused [CkXml_chilkatPath $xml "ReceiveMessageResult|Message[0]|Attribute|$"]

# rec is a CkXml
set rec [CkXml_FindNextRecord $xml "Name" "SenderId"]
puts "SenderId: [CkXml_getChildContent $rec Value]"
delete_CkXml $rec

set rec [CkXml_FindNextRecord $xml "Name" "ApproximateFirstReceiveTimestamp"]
puts "ApproximateFirstReceiveTimestamp: [CkXml_getChildContent $rec Value]"
delete_CkXml $rec

set rec [CkXml_FindNextRecord $xml "Name" "ApproximateReceiveCount"]
puts "ApproximateReceiveCount: [CkXml_getChildContent $rec Value]"
delete_CkXml $rec

set rec [CkXml_FindNextRecord $xml "Name" "SentTimestamp"]
puts "SentTimestamp: [CkXml_getChildContent $rec Value]"
delete_CkXml $rec

CkXml_GetRoot2 $xml

delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkXml $xml

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.