Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) MercadoLibre - Consultar mis datos personalesConsultar mis datos personales For more information, see https://developers.mercadolibre.com.ar/es_ar/servicios-consulta-usuarios
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) -- This example assumes the Chilkat API to have been previously unlocked. -- See Global Unlock Sample for sample code. DECLARE @http int -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END -- First get our previously obtained OAuth2 access token. DECLARE @jsonToken int -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jsonToken OUT DECLARE @success int EXEC sp_OAMethod @jsonToken, 'LoadFile', @success OUT, 'qa_data/tokens/mercadolibre.json' -- Implements the following CURL command: -- curl - X GET https://api.mercadolibre.com/users/me?access_token=$ACCESS_TOKEN -- Use the following online tool to generate HTTP code from a CURL command -- Convert a cURL Command to HTTP Source Code EXEC sp_OAMethod @jsonToken, 'StringOf', @sTmp0 OUT, 'access_token' EXEC sp_OAMethod @http, 'SetUrlVar', @success OUT, 'access_token', @sTmp0 DECLARE @sbResponseBody int -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://api.mercadolibre.com/users/me?access_token={$access_token}', @sbResponseBody IF @success = 0 BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @jsonToken EXEC @hr = sp_OADestroy @sbResponseBody RETURN END DECLARE @jResp int -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody EXEC sp_OASetProperty @jResp, 'EmitCompact', 0 PRINT 'Response Body:' EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT PRINT @sTmp0 DECLARE @respStatusCode int EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT PRINT 'Response Status Code = ' + @respStatusCode IF @respStatusCode >= 400 BEGIN PRINT 'Response Header:' EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT PRINT @sTmp0 PRINT 'Failed.' EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @jsonToken EXEC @hr = sp_OADestroy @sbResponseBody EXEC @hr = sp_OADestroy @jResp RETURN END -- Sample JSON response: -- (Sample code for parsing the JSON response is shown below) -- { -- "id": 202593498, -- "nickname": "TETE2870021", -- "registration_date": "2016-01-06T11: 31: 42.000-04: 00", -- "country_id": "AR", -- "address": { -- "state": "AR-C", -- "city": "Palermo" -- }, -- "user_type": "normal", -- "tags": [ -- "normal", -- "test_user", -- "user_info_verified" -- ], -- "logo": null, -- "points": 100, -- "site_id": "MLA", -- "permalink": "http://perfil.mercadolibre.com.ar/TETE2870021", -- "seller_reputation": { -- "level_id": null, -- "power_seller_status": null, -- "transactions": { -- "period": "historic", -- "total": 0, -- "completed": 0, -- "canceled": 0, -- "ratings": { -- "positive": 0, -- "negative": 0, -- "neutral": 0 -- } -- } -- }, -- "buyer_reputation": { -- "tags": [ -- ] -- }, -- "status": { -- "site_status": "active" -- } -- } -- Sample code for parsing the JSON response... -- Use the following online tool to generate parsing code from sample JSON: -- Generate Parsing Code from JSON DECLARE @strVal nvarchar(4000) DECLARE @id int EXEC sp_OAMethod @jResp, 'IntOf', @id OUT, 'id' DECLARE @nickname nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @nickname OUT, 'nickname' DECLARE @registration_date nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @registration_date OUT, 'registration_date' DECLARE @country_id nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @country_id OUT, 'country_id' DECLARE @addressState nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @addressState OUT, 'address.state' DECLARE @addressCity nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @addressCity OUT, 'address.city' DECLARE @user_type nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @user_type OUT, 'user_type' DECLARE @logo nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @logo OUT, 'logo' DECLARE @points int EXEC sp_OAMethod @jResp, 'IntOf', @points OUT, 'points' DECLARE @site_id nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @site_id OUT, 'site_id' DECLARE @permalink nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @permalink OUT, 'permalink' DECLARE @seller_reputationLevel_id nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @seller_reputationLevel_id OUT, 'seller_reputation.level_id' DECLARE @seller_reputationPower_seller_status nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @seller_reputationPower_seller_status OUT, 'seller_reputation.power_seller_status' DECLARE @seller_reputationTransactionsPeriod nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @seller_reputationTransactionsPeriod OUT, 'seller_reputation.transactions.period' DECLARE @seller_reputationTransactionsTotal int EXEC sp_OAMethod @jResp, 'IntOf', @seller_reputationTransactionsTotal OUT, 'seller_reputation.transactions.total' DECLARE @seller_reputationTransactionsCompleted int EXEC sp_OAMethod @jResp, 'IntOf', @seller_reputationTransactionsCompleted OUT, 'seller_reputation.transactions.completed' DECLARE @seller_reputationTransactionsCanceled int EXEC sp_OAMethod @jResp, 'IntOf', @seller_reputationTransactionsCanceled OUT, 'seller_reputation.transactions.canceled' DECLARE @seller_reputationTransactionsRatingsPositive int EXEC sp_OAMethod @jResp, 'IntOf', @seller_reputationTransactionsRatingsPositive OUT, 'seller_reputation.transactions.ratings.positive' DECLARE @seller_reputationTransactionsRatingsNegative int EXEC sp_OAMethod @jResp, 'IntOf', @seller_reputationTransactionsRatingsNegative OUT, 'seller_reputation.transactions.ratings.negative' DECLARE @seller_reputationTransactionsRatingsNeutral int EXEC sp_OAMethod @jResp, 'IntOf', @seller_reputationTransactionsRatingsNeutral OUT, 'seller_reputation.transactions.ratings.neutral' DECLARE @statusSite_status nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @statusSite_status OUT, 'status.site_status' DECLARE @i int SELECT @i = 0 DECLARE @count_i int EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'tags' WHILE @i < @count_i BEGIN EXEC sp_OASetProperty @jResp, 'I', @i EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'tags[i]' SELECT @i = @i + 1 END SELECT @i = 0 EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'buyer_reputation.tags' WHILE @i < @count_i BEGIN EXEC sp_OASetProperty @jResp, 'I', @i SELECT @i = @i + 1 END EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @jsonToken EXEC @hr = sp_OADestroy @sbResponseBody EXEC @hr = sp_OADestroy @jResp END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.