403エラーに関するすべての問題を読み、修正を試みても、次のURLとコードで403エラーが発生します。2つのSSLDLLファイルがディレクトリにあり、使用されているファイルuploaddata.txtが作業ディレクトリにあります。Indy9を搭載したDelphi7です。
URL:
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%3A28
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.
助けてくれてありがとう。この問題を抱えているのは、米国と英国の2人です。