我正在尝试使用idHTTP组件发布到Blogger,但是,我收到"HTTP/1.0 400 Bad Request"错误.
procedure TForm1.Button1Click(Sender: TObject);
var request,response,req : TStringlist;
auth,blogid : string;
begin
blogid := '00000000000000000000000';
request := TStringList.Create;
response := TStringList.Create;
req := TStringList.Create;
IdHTTP1.Request.Connection := 'Keep-Alive';
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdSSLIOHandlerSocket1.SSLOptions.Method := sslvSSLv23;
request.Clear();
request.Values['accountType'] := 'GOOGLE';
request.Values['Email'] := 'xxx@gmail.com';
request.Values['Passwd'] := 'yyy';
request.Values['service'] := 'blogger';
response.Text :=IdHTTP1.Post('https://www.google.com/accounts/ClientLogin',request);
auth := response.Values['Auth']; //working perfectly
req.Clear();
req.Text := Memo2.Lines.Text; //put entry into request var
IdHTTP1.Request.CustomHeaders.Clear();
IdHTTP1.Request.CustomHeaders.Add('GData-Version: 2');
//IdHTTP1.Request.CustomHeaders.Add('Authorization: GoogleLogin auth='+auth);
IdHTTP1.Request.CustomHeaders.Values['Authorization'] := 'GoogleLogin auth = '+auth;
IdHTTP1.Request.ContentType := 'application/atom+xml'; …Run Code Online (Sandbox Code Playgroud) 我不知道我的代码是对还是错.当我尝试运行程序时出现错误403 ..
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ssbase64, StdCtrls,secutils,OmniXMLUtils,OmniXML, xmldom,
XMLIntf, msxmldom, XMLDoc, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP,IdURI;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
XMLDocument1: TXMLDocument;
IdHTTP1: TIdHTTP;
Memo2: TMemo;
Memo3: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function MyEncodeUrl(source:string):string;
var i:integer;
begin
result := '';
for i := 1 to length(source) do
if not (source[i] in …Run Code Online (Sandbox Code Playgroud)