Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(MFC) MercadoLibre - Consultar mis datos personalesConsultar mis datos personales For more information, see https://developers.mercadolibre.com.ar/es_ar/servicios-consulta-usuarios
#include <CkHttp.h> #include <CkJsonObject.h> #include <CkStringBuilder.h> void ChilkatSample(void) { CkString strOut; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttp http; // First get our previously obtained OAuth2 access token. CkJsonObject jsonToken; bool success = jsonToken.LoadFile("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 http.SetUrlVar("access_token",jsonToken.stringOf("access_token")); CkStringBuilder sbResponseBody; success = http.QuickGetSb("https://api.mercadolibre.com/users/me?access_token={$access_token}",sbResponseBody); if (success == false) { strOut.append(http.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } CkJsonObject jResp; jResp.LoadSb(sbResponseBody); jResp.put_EmitCompact(false); strOut.append("Response Body:"); strOut.append("\r\n"); strOut.append(jResp.emit()); strOut.append("\r\n"); int respStatusCode = http.get_LastStatus(); strOut.append("Response Status Code = "); strOut.appendInt(respStatusCode); strOut.append("\r\n"); if (respStatusCode >= 400) { strOut.append("Response Header:"); strOut.append("\r\n"); strOut.append(http.lastHeader()); strOut.append("\r\n"); strOut.append("Failed."); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } // 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 // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat. // See this example explaining how this memory should be used: const char * functions. const char *strVal = 0; int id = jResp.IntOf("id"); const char *nickname = jResp.stringOf("nickname"); const char *registration_date = jResp.stringOf("registration_date"); const char *country_id = jResp.stringOf("country_id"); const char *addressState = jResp.stringOf("address.state"); const char *addressCity = jResp.stringOf("address.city"); const char *user_type = jResp.stringOf("user_type"); const char *logo = jResp.stringOf("logo"); int points = jResp.IntOf("points"); const char *site_id = jResp.stringOf("site_id"); const char *permalink = jResp.stringOf("permalink"); const char *seller_reputationLevel_id = jResp.stringOf("seller_reputation.level_id"); const char *seller_reputationPower_seller_status = jResp.stringOf("seller_reputation.power_seller_status"); const char *seller_reputationTransactionsPeriod = jResp.stringOf("seller_reputation.transactions.period"); int seller_reputationTransactionsTotal = jResp.IntOf("seller_reputation.transactions.total"); int seller_reputationTransactionsCompleted = jResp.IntOf("seller_reputation.transactions.completed"); int seller_reputationTransactionsCanceled = jResp.IntOf("seller_reputation.transactions.canceled"); int seller_reputationTransactionsRatingsPositive = jResp.IntOf("seller_reputation.transactions.ratings.positive"); int seller_reputationTransactionsRatingsNegative = jResp.IntOf("seller_reputation.transactions.ratings.negative"); int seller_reputationTransactionsRatingsNeutral = jResp.IntOf("seller_reputation.transactions.ratings.neutral"); const char *statusSite_status = jResp.stringOf("status.site_status"); int i = 0; int count_i = jResp.SizeOfArray("tags"); while (i < count_i) { jResp.put_I(i); strVal = jResp.stringOf("tags[i]"); i = i + 1; } i = 0; count_i = jResp.SizeOfArray("buyer_reputation.tags"); while (i < count_i) { jResp.put_I(i); i = i + 1; } SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.