Post 通过idHTTP向博主发布

Post 通过idHTTP向博主发布,post,c++builder,indy,blogger,idhttp,Post,C++builder,Indy,Blogger,Idhttp,我试图使用idHTTP组件向Blogger发帖,但是,我收到HTTP/1.0 400错误请求错误 request->Clear(); request->Text = Memo3->Lines->Text; //put entry into request var IdHTTP2->Request->CustomHeaders->Clear(); IdHTTP2->Request->CustomHeaders->Add("GData-

我试图使用idHTTP组件向Blogger发帖,但是,我收到HTTP/1.0 400错误请求错误

request->Clear();
request->Text = Memo3->Lines->Text;  //put entry into request var

IdHTTP2->Request->CustomHeaders->Clear();
IdHTTP2->Request->CustomHeaders->Add("GData-Version=2.0");
IdHTTP2->Request->CustomHeaders->Add("Authorization: GoogleLogin auth="+auth);
IdHTTP2->Request->ContentType = "application/atom+xml";

response->Text = IdHTTP2->Post("https://www.blogger.com/feeds/" + blogID + "/posts/default", request); // I got "HTTP/1.0 400 Bad Request" error right here.
首先,我得到了Auth代码,通过使用下面的代码,它可以完美地工作:

TStringList *request = new TStringList;
TStringList *response = new TStringList();

IdHTTP2->Request->Connection = "Keep-Alive";
IdHTTP2->Request->ContentType = "application/x-www-form-urlencoded";
IdSSLIOHandlerSocketOpenSSL1->SSLOptions->Method = sslvSSLv23;

request->Clear();
request->Values["accountType"] = "GOOGLE";
request->Values["Email"]       = "xxxxxxx@gmail.com";
request->Values["Passwd"]      = "yyyyyyy";
request->Values["source"]      = "test-test";
request->Values["service"]     = "blogger";

response->Text = IdHTTP2->Post("https://www.google.com/accounts/ClientLogin", request);
auth = response->Values["Auth"];  //working perfectly
然后,我得到blogID,最后我尝试使用下面的代码向Blogger发布一个条目,但此时我得到HTTP/1.0 400错误请求

request->Clear();
request->Text = Memo3->Lines->Text;  //put entry into request var

IdHTTP2->Request->CustomHeaders->Clear();
IdHTTP2->Request->CustomHeaders->Add("GData-Version=2.0");
IdHTTP2->Request->CustomHeaders->Add("Authorization: GoogleLogin auth="+auth);
IdHTTP2->Request->ContentType = "application/atom+xml";

response->Text = IdHTTP2->Post("https://www.blogger.com/feeds/" + blogID + "/posts/default", request); // I got "HTTP/1.0 400 Bad Request" error right here.
这是我试图发布的条目:

<entry xmlns='http://www.w3.org/2005/Atom'>
  <title type='text'>Marriage!</title>
  <content type='xhtml'>
    <div xmlns="http://www.w3.org/1999/xhtml">
      <p>Mr. Darcy has <em>proposed marriage</em> to me!</p>
      <p>He is the last man on earth I would ever desire to marry.</p>
      <p>Whatever shall I do?</p>
    </div>
  </content>
  <category scheme="http://www.blogger.com/atom/ns#" term="marriage" />
  <category scheme="http://www.blogger.com/atom/ns#" term="Mr. Darcy" />
</entry>
我已经寻找了一种使用idHTTP发布的正确方法,但我没有发现任何东西..:

有人知道我做错了什么吗

顺便说一句,我使用的是CodeGear Delphi/C++Builder 2009,Indy的版本是10

非常感谢您的帮助。
谢谢大家!

我找到了让它工作的方法

我拔掉了线

 IdHTTP2->Request->CustomHeaders->Add("GData-Version=2.0");
然后我换了

 IdHTTP2->Request->CustomHeaders->Add("Authorization: GoogleLogin auth="+auth);


发件人:

乍一看没有发现问题,您可以尝试确保身份验证令牌中没有多余的空格。我经历了很长一段时间的400秒,直到我意识到我在标题中的Auth标记末尾获得了一个额外的空间。