3
我试图使用idHTTP组件发布到Blogger,但是,我收到“HTTP/1.0 400错误请求”错误。在blogger via idHTTP:错误400错误请求
memo1.Text := IdHTTP1.Post('https://www.blogger.com/feeds/' + blogid + '/posts/default', req);
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'] := '[email protected]';
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';
memo1.Text := IdHTTP1.Post('https://www.blogger.com/feeds/' + blogid + '/posts/default', req); // I got "HTTP/1.0 400 Bad Request" error right here.
end;
GOR错误有谁知道我做错了吗?
任何帮助,非常感谢。谢谢!
谢谢,但尝试您的解决方案后,我得到了“HTTP/1.0 401未经授权 –
对不起只需要在这里删除空格.. IdHTTP1。 Request.CustomHeaders.Values ['Authorization']:='GoogleLogin auth ='+ auth; –
如果它正在工作,那么您会接受答案吗? –