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
|
Simple HTTP POSTDemonstrates a simple HTTP POST. CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @sTmp0 nvarchar(4000) DECLARE @req int EXEC @hr = sp_OACreate 'Chilkat.HttpRequest', @req OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @http int EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int -- Any string unlocks the component for the 1st 30-days. EXEC sp_OAMethod @http, 'UnlockComponent', @success OUT, 'Anything for 30-day trial' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END -- This example simulates this FORM: -- <form action="processPost.asp" method="post"> -- First name: <input type="text" name="firstName"><br /> -- Last name: <input type="text" name="lastName"><br /> -- <input type="submit" value="Submit"> -- </form> -- The online FORM is found at this URL: -- http://www.chilkatsoft.com/simpleForm.html -- Build an HTTP POST Request: EXEC sp_OAMethod @req, 'UsePost', NULL -- The FORM target is http://www.chilkatsoft.com/processPost.asp -- An easy way of filling out most of the HTTP request object -- is to call SetFromUrl: EXEC sp_OAMethod @req, 'SetFromUrl', NULL, 'http://www.chilkatsoft.com/processPost.asp' -- The only remaining task is to add the params to the -- HTTP request object: EXEC sp_OAMethod @req, 'AddParam', NULL, 'firstName', 'Matt' EXEC sp_OAMethod @req, 'AddParam', NULL, 'lastName', 'Jones' -- Send the HTTP POST and get the response. -- The POST is being sent to chilkatsoft.com, on port 80 -- (the default HTTP port), and not using SSL. DECLARE @domain nvarchar(4000) DECLARE @port int DECLARE @ssl int SELECT @domain = 'chilkatsoft.com' SELECT @port = 80 SELECT @ssl = 0 -- The HTTP POST is sent here: DECLARE @resp int EXEC sp_OAMethod @http, 'SynchronousRequest', @resp OUT, @domain, @port, @ssl, @req IF @resp Is NULL BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 END ELSE BEGIN -- Display the HTML source of the page returned. EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT PRINT @sTmp0 END END GO |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.