0

在阅读了 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.

谢谢你的帮助。我们两个人有这个问题,一个在美国,一个在英国

4

1 回答 1

1

403 表示您正在尝试访问您无权访问的 URL。因此,要么您缺少必需的身份验证步骤,要么您提供的身份验证错误。

于 2012-07-21T04:48:37.327 回答