piXologisch EasyAnalyse – Anmeldung an Google, Download Account-Feeds

procedure TForm1.Button6Click(Sender: TObject);
var  EncodedDataString: string;
PostData: OleVariant;
Headers: OleVariant;
i: integer;
value: string;
begin
EncodedDataString :=
‚Email=’+HTTPEncode(‚‘)+’&’+
‚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).

  1. procedure TForm1.Button6Click(Sender: TObject);
  2. var  EncodedDataString: string;
  3. PostData: OleVariant;
  4. Headers: OleVariant;
  5. i: integer;
  6. value: string;
  7. begin
  8. EncodedDataString :=
  9. ‚Email=’+HTTPEncode(‚deineemail‘)+’&’+
  10. ‚Passwd=’+HTTPEncode(‚deinpasswort‘)+’&’+
  11. ‚accountType=’+httpencode(‚GOOGLE‘)+’&’+
  12. ’service=’+httpencode(‚analytics‘);
  13. PostData := VarArrayCreate([0, length(EncodedDataString)-1], varByte);
  14. for i := 1 to length(EncodedDataString) do
  15. PostData[i-1] := ord(EncodedDataString[i]);
  16. Headers := ‚Content-type: application/x-www-form-urlencoded’#10#13;
  17. WebBrowser1.Navigate(‚https://www.google.com/accounts/ClientLogin‘,
  18. EmptyParam, EmptyParam, PostData, Headers);
  19. end;
  20. procedure TForm1.Button7Click(Sender: TObject);
  21. begin
  22. with IdHTTP1 do begin
  23. // IOHandler := IdSSLIOHandlerSocket1;
  24. ProxyParams.BasicAuthentication := False;
  25. Request.UserAgent := ‚Mozilla/3.0 (compatible; Indy Library)‘;
  26. Request.ContentType := ‚application/x-www-form-urlencoded‘;
  27. request.host := ‚www.google.com‘;
  28. request.connection := ‚keep-alive‘;
  29. Request.Accept := ‚text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2‘;
  30. end;
  31. idhttp1.Request.CustomHeaders.Add(‚Authorization: GoogleLogin auth=“‚+zwischen+'“ ‚);
  32. memo4.Text:=idhttp1.Get(‚https://www.google.com/analytics/feeds/accounts/default‘);
  33. memo4.Text:= StringReplace( memo4.Text, ‚>‘, ‚>’+#13#10, [rfReplaceAll, rfIgnoreCase]);
  34. end;

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.