procedure TForm1.Button6Click(Sender: TObject);
var EncodedDataString: string;
PostData: OleVariant;
Headers: OleVariant;
i: integer;
value: string;
begin
EncodedDataString :=
‚Email=’+HTTPEncode(‚info@pixologisch.de‘)+’&’+
‚Passwd=’+HTTPEncode(‚hansu1977‘)+’&’+
‚accountType=’+httpencode(‚GOOGLE‘)+’&’+
’service=’+httpencode(‚analytics‘);
// The PostData OleVariant needs to be an array of bytes
// as large as the string (minus the 0 terminator)
PostData := VarArrayCreate([0, length(EncodedDataString)-1], varByte);
// Now, move the Ordinal value of the character into the PostData array
for i := 1 to length(EncodedDataString) do
PostData[i-1] := ord(EncodedDataString[i]);
Headers := ‚Content-type: application/x-www-form-urlencoded’#10#13;
// Parameters 2 and 3 are not used, thus EmptyParam is passed.
WebBrowser1.Navigate(‚https://www.google.com/accounts/ClientLogin‘,
EmptyParam, EmptyParam, PostData, Headers);
// memo4.Text:=idhttp1.Post(‚https://www.google.com/accounts/ClientLogin‘,EncodedDataString);
end;
Der folgende Code zeigt die Anmeldung an die Google-Services (Button6). Nach Übergabe der Daten werden die Tokens ausgegeben und für die weitere Verwendung aufbereitet (Button7).
- procedure TForm1.Button6Click(Sender: TObject);
- var EncodedDataString: string;
- PostData: OleVariant;
- Headers: OleVariant;
- i: integer;
- value: string;
- begin
- EncodedDataString :=
- ‚Email=’+HTTPEncode(‚deineemail‘)+’&’+
- ‚Passwd=’+HTTPEncode(‚deinpasswort‘)+’&’+
- ‚accountType=’+httpencode(‚GOOGLE‘)+’&’+
- ’service=’+httpencode(‚analytics‘);
- PostData := VarArrayCreate([0, length(EncodedDataString)-1], varByte);
- for i := 1 to length(EncodedDataString) do
- PostData[i-1] := ord(EncodedDataString[i]);
- Headers := ‚Content-type: application/x-www-form-urlencoded’#10#13;
- WebBrowser1.Navigate(‚https://www.google.com/accounts/ClientLogin‘,
- EmptyParam, EmptyParam, PostData, Headers);
- end;
- procedure TForm1.Button7Click(Sender: TObject);
- begin
- with IdHTTP1 do begin
- // IOHandler := IdSSLIOHandlerSocket1;
- ProxyParams.BasicAuthentication := False;
- Request.UserAgent := ‚Mozilla/3.0 (compatible; Indy Library)‘;
- Request.ContentType := ‚application/x-www-form-urlencoded‘;
- request.host := ‚www.google.com‘;
- request.connection := ‚keep-alive‘;
- Request.Accept := ‚text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2‘;
- end;
- idhttp1.Request.CustomHeaders.Add(‚Authorization: GoogleLogin auth=“‚+zwischen+'“ ‚);
- memo4.Text:=idhttp1.Get(‚https://www.google.com/analytics/feeds/accounts/default‘);
- memo4.Text:= StringReplace( memo4.Text, ‚>‘, ‚>’+#13#10, [rfReplaceAll, rfIgnoreCase]);
- end;