Send rest requests to amazon web services with visual foxpro (posible signature error)
I'm trying to send instructions in order to create a new SimpleDB domain using VFP9.
The .fll library come thanks to sweet potato software, and the hour difference was solved using an additional variable. I've seen other samples with java and php here. Also, I'been checking the aws developer page for examples on this:
http://docs.amazonwebservices.com/AmazonSimpleDB/latest/DeveloperGuide/index.html?REST_RESTAuth.html http://docs.amazonwebservices.com/AmazonSimpleDB/latest/DeveloperGuide/SDB_API_CreateDomain.html
but still, no luck. I've made a .prg file for test my connection, and receive a:
<?xml version="1.0"?>
<Response><Errors><Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</Message></Error></Errors><RequestID>2e4718de-4ba2-2f76-开发者_如何学C0aad-a7f3a4c86ab5</RequestID></Response>
Here's the code for my .prg:
* http://www.sweetpotatosoftware.com/SPSBlog/2009/08/09/MajorVFPEncryptionUpdate.aspx
SET LIBRARY TO ('vfpencryption71.fll')
PUBLIC cURL_AWS_SDBService
PUBLIC cAWSAccessKeyId
PUBLIC cAWSSecretAccessKey
PUBLIC cAWS_Action
PUBLIC cAWS_SignatureMethod
PUBLIC cAWS_SignatureVersion
PUBLIC cAWS_Version
PUBLIC cAWS_TimeStamp
PUBLIC cAWS_Signature
PUBLIC nAWS_UTCDifference
nAWS_UTCDifference = 5
cURL_AWS_SDBService = 'https://sdb.amazonaws.com'
cAWS_Action = 'CreateDomain'
cAWSAccessKeyId = (MY_ACCESS_ID)
cAWSSecretAccessKey = (MY_SECRET_ACCESS_KEY)
cAWS_TimeStamp = STRTRAN(STRCONV(TTOC(DATETIME() + (60 * 60 * nAWS_UTCDifference),3),9),':','%3A') + '-00%3A00'
cAWS_SignatureVersion = '2'
cAWS_SignatureMethod = 'HmacSHA256'
cAWS_Version = '2009-04-15'
LOCAL cFirma
SET TEXTMERGE on
TEXT TO cFirma noshow
GET\n<<cURL_AWS_SDBService>>\n/\nAWSAccessKeyId=<<cAWSAccessKeyId>>&Action=<<cAWS_Action>>&DomainName=Atoq_SDB&SignatureMethod=<<cAWS_SignatureMethod>>&SignatureVersion=<<cAWS_SignatureVersion>>&Timestamp=<<cAWS_TimeStamp>>&Version=<<cAWS_Version>>
ENDTEXT
SET TEXTMERGE off
clear
?cFirma
cAWS_Signature = HMAC(cFirma,cAWSSecretAccessKey ,2)
cAWS_Signature = STRCONV(cAWS_Signature,15)
?
?cAWS_Signature
?
SET TEXTMERGE on
TEXT TO cCadena noshow
<<cURL_AWS_SDBService>>/?Action=<<cAWS_Action>>&AWSAccessKeyId=<<cAWSAccessKeyId>>&DomainName=New_Database&SignatureVersion=<<cAWS_SignatureVersion>>&SignatureMethod=<<cAWS_SignatureMethod>>&Timestamp=<<cAWS_TimeStamp>>&Version=<<cAWS_Version>>&Signature=<<cAWS_Signature>>
ENDTEXT
SET TEXTMERGE off
?cCadena
?
objSrvHTTP = CreateObject ("Msxml2.ServerXMLHTTP.3.0")
objSrvHTTP.open('GET',cCadena, .F.)
objSrvHTTP.send()
?objSrvHTTP.responseText
What i'm doing wrong here?
TIA
Dumb question but, are you using STRCONV(cAWS_Signature,15) instead of STRCONV(cAWS_Signature,13) on purpose? The Amazon docs makes a reference to Base64Encode(Signature) which is what the 13 seems to mean in VFP9's help file for strconv()
精彩评论