在阅读了 403 错误的所有问题并尝试修复后,我仍然收到带有以下 URL 和代码的 403 错误。目录中存在两个 SSL DLL 文件,并且正在使用的文件 uploaddata.txt 位于工作目录中。它是 Delphi 7 和 Indy 9。
网址:
https://mws.amazonservices.com/?AWSAccessKeyId=A *&Action=SubmitFeed&FeedType=_POST_FLAT_FILE_INVLOADER_DATA_&Merchant=A* &PurgeAndReplace=false&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-07-20T21%3A39%3A28Z&Version=2009-01-01&Signature=MRJFSuBsqdUE7SaoUFdXO5zY2YFOc4QjVxg0lOISSis%3D
unit MWSDemo;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, HTTPApp, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdHTTP, IdIOHandler, IdIOHandlerSocket,
IdSSLOpenSSL, IdServerIOHandler, IdAntiFreezeBase, IdAntiFreeze,
IdMultipartFormData;
type
TForm1 = class(TForm)
Button1: TButton;
HTTPS: TIdHTTP;
IdAntiFreeze1: TIdAntiFreeze;
IdServerIOHandlerSSL1: TIdServerIOHandlerSSL;
IdSSLIOHandlerSocket1: TIdSSLIOHandlerSocket;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses hash, hmac, sha256, mem_util;
function GetMWSRequest : string;
var
ctx: THMAC_Context;
< more code here>
var
UTC: TSystemTime;
begin
GetSystemTime(UTC);
AmazonTimestamp:=HTTPDecode(Format('%.2d', [UTC.wYear]) + '-'
+ Format('%.2d', [UTC.wMonth]) + '-' + Format('%.2d', [UTC.wDay]) + 'T'
+ Format('%.2d', [UTC.wHour]) + ':' + Format('%.2d', [UTC.wMinute]) + ':' +
Format('%.2d', [UTC.wSecond]) + 'Z');
AmazonURL:='https://mws.amazonservices.com/?';
< more code here>
Result:=AmazonURL;
end;
procedure TForm1.Button1Click(Sender: TObject);
var URL, Response: string;
Stream : TStringStream;
Params: TIdMultipartFormDataStream;
begin
URL := GetMWSRequest;
HTTPS.Request.BasicAuthentication := true;
HTTPS.Request.ContentType := 'text/html';
IdSSLIOHandlerSocket1.SSLOptions.Method := TIdSSLVersion(sslvSSLv23);
HTTPS.IOHandler := IdSSLIOHandlerSocket1;
try
Stream := TStringStream.Create('');
Params := TIdMultipartFormDataStream.Create;
Params.AddFile('File1', 'UploadData.txt','application/octet-stream');
try
HTTPS.Post(URL, Params, Stream);
Memo2.Text := HTTPS.ResponseText;
finally
Stream.Free;
Params.Free;
end;
except
on E: Exception do
ShowMessage('** Error: ' + e.Message);
end;
end;
end.
谢谢你的帮助。我们两个人有这个问题,一个在美国,一个在英国