Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Add URL to Del.icio.us via HTTPS APIAdd a new URL to del.icio.us. CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @sTmp0 nvarchar(4000) 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 -- del.icio.us uses HTTP-Auth, which means you only need -- to set your login/password here: EXEC sp_OASetProperty @http, 'Login', 'chilkatsoft' EXEC sp_OASetProperty @http, 'Password', 'MyPassword' -- Create a request and add the info: DECLARE @req int EXEC @hr = sp_OACreate 'Chilkat.HttpRequest', @req OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END EXEC sp_OAMethod @req, 'AddParam', NULL, 'url', 'http://www.chilkatsoft.com/' EXEC sp_OAMethod @req, 'AddParam', NULL, 'description', 'Chilkat Software, Inc.' EXEC sp_OAMethod @req, 'AddParam', NULL, 'tags', 'chilkat components activex library software' -- There are other optional params that can be added, -- but we'll skip those. More information is at: -- http://del.icio.us/help/api/posts -- Indicate the HTTP method desired (POST or GET) EXEC sp_OAMethod @req, 'UseGet', NULL -- The path is: /v1/posts/add EXEC sp_OASetProperty @req, 'Path', '/v1/posts/add' -- Notice that the URL is this: -- https://api.del.icio.us/v1/posts/add?.... -- -- The domain = api.del.icio.us -- We're using HTTPS, so the port = 443, and we set the SSL argument to true (below) -- The "path" part of the URL is "/v1/posts/add" -- Send the HTTPS GET and get the response. Note: This is a blocking call. -- The method does not return until the full HTTPS response is received. DECLARE @domain nvarchar(4000) DECLARE @port int DECLARE @ssl int SELECT @domain = 'api.del.icio.us' 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 -- Check the XML returned: -- We should have a <result code="done" /> 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.