TLama

Untitled

Mar 25th, 2013
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.38 KB | None | 0 0
  1. uses
  2.   IdHTTP, IdSSLOpenSSL;
  3.  
  4. function TfrmMain.Login: string;
  5. var
  6.   IdHTTP: TIdHTTP;
  7.   Request: TStringList;
  8.   Response: TMemoryStream;
  9.   SSLHandler: TIdSSLIOHandlerSocketOpenSSL;
  10. begin
  11.   Result := '';
  12.   try
  13.     Response := TMemoryStream.Create;
  14.     try
  15.       Request := TStringList.Create;
  16.       try
  17.         Request.Add('op=login');
  18.         Request.Add('redirect=http://newyork.craigslist.org/');
  19.         Request.Add('login=' + myEmail);
  20.         Request.Add('password=' + myPassword);
  21.         IdHTTP := TIdHTTP.Create;
  22.         try
  23.           SSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
  24.           try
  25.             SSLHandler.SSLOptions.Method := sslvSSLv3;
  26.             SSLHandler.SSLOptions.Mode := sslmUnassigned;
  27.  
  28.             IdHTTP.IOHandler := SSLHandler;
  29.             IdHTTP.AllowCookies := True;
  30.             IdHTTP.HandleRedirects := True;
  31.             IdHTTP.Request.ContentType := 'application/x-www-form-urlencoded';
  32.             IdHTTP.Post('https://accounts.craigslist.org/login', Request, Response);
  33.             Result := IdHTTP.Get('https://accounts.craigslist.org/');
  34.           finally
  35.             SSLHandler.Free;
  36.           end;
  37.         finally
  38.           IdHTTP.Free;
  39.         end;
  40.       finally
  41.         Request.Free;
  42.       end;
  43.     finally
  44.       Response.Free;
  45.     end;
  46.   except
  47.     on E: Exception do
  48.       ShowMessage(E.Message);
  49.   end;
  50. end;
Advertisement
Add Comment
Please, Sign In to add comment