Sample code for 30+ languages & platforms
Lianja

MercadoLibre - Consultar mis datos personales

See more MercadoLibre Examples

Consultar mis datos personales

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loHttp = createobject("CkHttp")

// First get our previously obtained OAuth2 access token.
loJsonToken = createobject("CkJsonObject")
llSuccess = loJsonToken.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

loHttp.SetUrlVar("access_token",loJsonToken.StringOf("access_token"))

loSbResponseBody = createobject("CkStringBuilder")
llSuccess = loHttp.QuickGetSb("https://api.mercadolibre.com/users/me?access_token={$access_token}",loSbResponseBody)
if (llSuccess = .F.) then
    ? loHttp.LastErrorText
    release loHttp
    release loJsonToken
    release loSbResponseBody
    return
endif

loJResp = createobject("CkJsonObject")
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = .F.

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loHttp.LastStatus
? "Response Status Code = " + str(lnRespStatusCode)
if (lnRespStatusCode >= 400) then
    ? "Response Header:"
    ? loHttp.LastHeader
    ? "Failed."
    release loHttp
    release loJsonToken
    release loSbResponseBody
    release loJResp
    return
endif

// 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

lnId = loJResp.IntOf("id")
lcNickname = loJResp.StringOf("nickname")
lcRegistration_date = loJResp.StringOf("registration_date")
lcCountry_id = loJResp.StringOf("country_id")
lcAddressState = loJResp.StringOf("address.state")
lcAddressCity = loJResp.StringOf("address.city")
lcUser_type = loJResp.StringOf("user_type")
lcLogo = loJResp.StringOf("logo")
lnPoints = loJResp.IntOf("points")
lcSite_id = loJResp.StringOf("site_id")
lcPermalink = loJResp.StringOf("permalink")
lcSeller_reputationLevel_id = loJResp.StringOf("seller_reputation.level_id")
lcSeller_reputationPower_seller_status = loJResp.StringOf("seller_reputation.power_seller_status")
lcSeller_reputationTransactionsPeriod = loJResp.StringOf("seller_reputation.transactions.period")
lnSeller_reputationTransactionsTotal = loJResp.IntOf("seller_reputation.transactions.total")
lnSeller_reputationTransactionsCompleted = loJResp.IntOf("seller_reputation.transactions.completed")
lnSeller_reputationTransactionsCanceled = loJResp.IntOf("seller_reputation.transactions.canceled")
lnSeller_reputationTransactionsRatingsPositive = loJResp.IntOf("seller_reputation.transactions.ratings.positive")
lnSeller_reputationTransactionsRatingsNegative = loJResp.IntOf("seller_reputation.transactions.ratings.negative")
lnSeller_reputationTransactionsRatingsNeutral = loJResp.IntOf("seller_reputation.transactions.ratings.neutral")
lcStatusSite_status = loJResp.StringOf("status.site_status")
i = 0
lnCount_i = loJResp.SizeOfArray("tags")
do while i < lnCount_i
    loJResp.I = i
    lcStrVal = loJResp.StringOf("tags[i]")
    i = i + 1
enddo
i = 0
lnCount_i = loJResp.SizeOfArray("buyer_reputation.tags")
do while i < lnCount_i
    loJResp.I = i
    i = i + 1
enddo


release loHttp
release loJsonToken
release loSbResponseBody
release loJResp