Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Amazon AIM - Generate Order Fulfillment ReportAmazon AIM API -- Generate an Order Fulfillment Report 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 -- The CookieDir may be set to "memory" to keep an in-memory cache of cookies. -- Alternatively, you may set it to a directory, such as "c:/temp/cookies". If you do that, -- you can visually browse the cookies which will appear as XML files in the CookieDir. EXEC sp_OASetProperty @http, 'CookieDir', 'memory' -- Tell the HTTP component to save any cookies received. Also tell the component to -- re-send cookies with subsequent GETs and POSTs. EXEC sp_OASetProperty @http, 'SendCookies', 1 EXEC sp_OASetProperty @http, 'SaveCookies', 1 -- Build an HTTP POST Request: EXEC sp_OAMethod @req, 'UsePost', NULL EXEC sp_OASetProperty @req, 'Path', '/exec/panama/seller-admin/manual-reports/generate-report-now' -- Setting your login/password causes Chilkat to automatically add the Authorization header: EXEC sp_OASetProperty @http, 'Login', 'MyLogin' EXEC sp_OASetProperty @http, 'Password', 'MyPassword' EXEC sp_OAMethod @req, 'AddHeader', NULL, 'Content-Type', 'text/xml' EXEC sp_OAMethod @req, 'AddHeader', NULL, 'NumberofDays', '30' EXEC sp_OAMethod @req, 'AddHeader', NULL, 'ReportName', 'Order' -- 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. DECLARE @domain nvarchar(4000) DECLARE @port int DECLARE @ssl int SELECT @domain = 'merchant-query.amazon.com' SELECT @port = 443 SELECT @ssl = 1 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 XML returned. EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT PRINT @sTmp0 END END GO |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.