idHTTPコンポーネントを使用してBloggerに投稿しようとしていますが、「HTTP / 1.0400BadRequest」エラーが発生します。
まず、以下のコードを使用して完全に機能する認証コードを取得します。
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.0400BadRequest」エラーが発生します。
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です。
どんな助けでも大歓迎です。ありがとうございました!