Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
HTTPS Form LoginUsing the del.icio.us site, demonstrates how to programmatically login via a form. LOCAL loReq LOCAL loHttp LOCAL lnSuccess LOCAL lcHtml LOCAL lcDomain LOCAL lnPort LOCAL lnSsl LOCAL loResp LOCAL lnResponseStatus loReq = CreateObject('Chilkat.HttpRequest') loHttp = CreateObject('Chilkat.Http') * Any string unlocks the component for the 1st 30-days. lnSuccess = loHttp.UnlockComponent("Anything for 30-day trial") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loHttp.LastErrorText) QUIT ENDIF * Cookies may be persisted to a directory in the filesystem, * or alternatively cached in memory by using the "memory" * keyword: loHttp.CookieDir = "memory" * Accumulated cookies are sent with each GET/POST: loHttp.SaveCookies = 1 * Cookies received in HTTP responses are to be saved: loHttp.SendCookies = 1 * Get the page with the login form. We're only doing this * just in case there are cookies that need to be cached * and re-sent in the next step: lcHtml = loHttp.QuickGetStr("https://secure.del.icio.us/login") IF (loHttp.LastStatus <> 200) THEN =MESSAGEBOX(loHttp.LastErrorText) QUIT ENDIF * Examining the "Page Info" in FireFox reveals a form with * a target of https://secure.del.icio.us/login with * fields of "user_name", "password", and "login". The "login" * field is nothing more than the submit button and holds * the value "log in". * Build an HTTP POST Request: loReq.UsePost() loReq.Path = "/login" loReq.AddParam("user_name","chilkatsoft") loReq.AddParam("password","****") loReq.AddParam("login","log in") * Send the HTTP POST and get the response. Note: This is a blocking call. * The method does not return until the full HTTP response is received. lcDomain = "secure.del.icio.us" lnPort = 443 lnSsl = 1 loResp = loHttp.SynchronousRequest(lcDomain,lnPort,lnSsl,loReq) IF (loResp = NULL ) THEN ? loHttp.LastErrorText ELSE lnResponseStatus = loResp.StatusCode IF (lnResponseStatus = 302) THEN * We have a redirect. Follow it... * Note: the FollowRedirects property causes * 301/302 responses to GET requests to be * automatically followed. loHttp.FollowRedirects = 1 lcHtml = loHttp.QuickGetStr(loResp.GetHeaderField("Location")) IF (loHttp.LastStatus <> 200) THEN =MESSAGEBOX(loHttp.LastErrorText) QUIT ENDIF ELSE lcHtml = loResp.BodyStr ENDIF ? STR(lnResponseStatus) * Display the HTML source of the page returned. ? lcHtml ENDIF |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.
Mail Component · .NET Email Component · ASP Mail Component · XML Parser