Beating my head with query to Amazon AWS with coldfusion

I have been beating my head senseless for sometime now with trying to query amazon's aws.  When I run my code I get an error stating that the signature is invalid so now I turn to you Experts for your valued help.

Here is my code.

 <cffunction name="awsurl" returntype="string" access="public" output="No">
 <cfargument name="Query" type="string" required="true" />
 <cfargument name="AWSAccessKeyId" type="string" required="true"  default="AKIAJxxxxxxxx"/>
 <cfargument name="SecretKey" type="string" required="true" default="xxxxxxxxxxxxx>
 <cfargument name="Host" type="string" default="" />
 <cfargument name="Methord" type="string" default="GET" />
 <cfargument name="URI" type="string" default="/" />
 <cfargument name="SignatureVersion" type="string" default="2" />
 <cfargument name="Version" type="date" default="2012-04-01" />
 <cfargument name="http" type="string" default="https" hint="https|http" />
 <!--- add common values --->
 <cfset local.Time = dateConvert("local2Utc",now())>
 <cfset local.Time = "#DateFormat(local.Time,'yyyy-mm-dd')#T#TimeFormat(local.Time,'HH:mm:ss')#">
 <cfset arguments.Query = "#arguments.Query#&Timestamp=#local.Time#&SignatureVersion=#arguments.SignatureVersion#&Version=#arguments.Version#&SignatureMethod=HmacSHA256">
 <!--- sort QueryString --->
 <cfset arguments.Query = ListToArray(arguments.Query,'&')>
 <cfset ArraySort(arguments.Query,'text')>
 <!--- prepend AccessKeyID --->
 <cfset ArrayPrepend(arguments.Query, "AWSAccessKeyId=#arguments.AWSAccessKeyId#")>
<!--- url encode each values --->
 <cfset local.SortedString = ArrayNew(1)>
 <cfloop from="1" to="#ArrayLen(arguments.Query)#" index="local.i">
 <cfset local.value = arguments.Query[local.i]>
 <cfif listlen(local.value,'=') gt 1>
 <cfset ArrayAppend(local.SortedString,"#listfirst(local.value,'=')#=#reservedEncod(listlast(local.value,'='))#")>
 <cfset ArrayAppend(local.SortedString,"#local.value#")>
<!--- create signature string --->
 <cfset local.toEncode = "#arguments.Methord##chr(10)##arguments.Host##chr(10)##arguments.URI##chr(10)##ArrayToList(local.SortedString,'&')#">
 <!--- encode Signature String --->
 <cfset local.Signature = URLEncodedFormat(ToBase64(HMAC_SHA256(local.toEncode,arguments.SecretKey)))>
 <cfset arguments.Query = ArrayToList(arguments.Query,'&')>
 <cfset arguments.Query = "#arguments.http#://#arguments.Host##arguments.URI#?#arguments.Query#&Signature=#local.Signature#">
 <cfreturn arguments.Query>
<!--- ********************************************************************* --->
<cffunction name="reservedEncod" returntype="string" access="public" output="no">
 <cfargument name="string" type="string" required="true" />
 <cfset local.reserved = "!|##|$|&|'|(|)|*|+|,|/|:|;|=|?|@|[|]| ">
 <cfloop list="#local.reserved#" index="local.i" delimiters="|">
 <cfif find(local.i,arguments.string)>
 <cfset arguments.string = replace(arguments.string,local.i, "%#ucase(FormatBaseN(Asc(local.i),'16'))#", 'all')>
 <cfreturn arguments.string>
<!--- ********************************************************************* --->
<cffunction name="HMAC_SHA256" returntype="binary" access="public" output="no">
 <cfargument name="signMessage" type="string" required="true" />
 <cfargument name="signKey" type="string" required="true" />
 <cfset local.jMsg = JavaCast("string",arguments.signMessage).getBytes("iso-8859-1") />
 <cfset local.jKey = JavaCast("string",arguments.signKey).getBytes("iso-8859-1") />
 <cfset local.key = createObject("java","javax.crypto.spec.SecretKeySpec") />
 <cfset local.mac = createObject("java","javax.crypto.Mac") />
 <cfset local.key = local.key.init(local.jKey,"HmacSHA256") />
 <cfset local.mac = local.mac.getInstance(local.key.getAlgorithm()) />
 <cfset local.mac.init(local.key) />
 <cfset local.mac.update(local.jMsg) />
 <cfreturn local.mac.doFinal() />
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jriver12Author Commented:
Also have tried with JavaScript:
<!DOCTYPE html>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">


<div class="container">


<script src="jquery.js"></script>
<script src="jquery.xdomainajax.js"></script>



    url: ''+
    type: 'get',
    dataType: "xml",
    success: function(res) {

        var xml = $.parseXML(res.responseText);
        var $tmp = $( xml );
        var tmp2 = $tmp.find( "head" );

      error: function(){


jriver12Author Commented:
my third attempt see attached. (error with complex variables)
one thing to check is if it is expiring too soon.
add some minutes to the time stamp.

also look at this:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

jriver12Author Commented:
got it working using this method(attached) however it is only returning the first few of 100/1000 results.  I need to view and return all and am hitting a wall. any suggestions would be great.
jriver12Author Commented:
Thanks for the pointer but Im not using php, I'm Using ColdFusion.

Not to mention I am clueless on php.
yes - i know you are on CF.
you are typically hard pressed to find CF code examples - especially from large companies - so we usually read through PHP or whatever and glean what we can understand.
note that you don't need to understand everything - just looking for clues ...
I've requested that this question be deleted for the following reason:

The question has either no comments or not enough useful information to be called an "answer".
I would say that I answered his question - see this post: http:#a40476395 but poster then asked for help with the number of records it returned - which was not in the original question.
I did try to provide more help but admittedly did not provide a lot of useful additional info.

Thanks ...
jriver12Author Commented:
Points have been awarded for answer.  Dgrafx is correct in declaring that an answer was provided which helped in resolving initial issue.
Thanks !
jriver12Author Commented:
Thank you for your assistance, excuse my delay.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Services

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.