Sample code for 30+ languages & platforms
Xbase++

MercadoLibre - Consultar mis datos personales

See more MercadoLibre Examples

Consultar mis datos personales

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL oJsonToken
LOCAL oSbResponseBody
LOCAL oJResp
LOCAL nRespStatusCode
LOCAL cStrVal
LOCAL nId
LOCAL cNickname
LOCAL cRegistration_date
LOCAL cCountry_id
LOCAL cAddressState
LOCAL cAddressCity
LOCAL cUser_type
LOCAL cLogo
LOCAL nPoints
LOCAL cSite_id
LOCAL cPermalink
LOCAL cSeller_reputationLevel_id
LOCAL cSeller_reputationPower_seller_status
LOCAL cSeller_reputationTransactionsPeriod
LOCAL nSeller_reputationTransactionsTotal
LOCAL nSeller_reputationTransactionsCompleted
LOCAL nSeller_reputationTransactionsCanceled
LOCAL nSeller_reputationTransactionsRatingsPositive
LOCAL nSeller_reputationTransactionsRatingsNegative
LOCAL nSeller_reputationTransactionsRatingsNeutral
LOCAL cStatusSite_status
LOCAL i
LOCAL nCount_i

nSuccess := 0

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

oHttp := CreateObject("Chilkat.Http")

//  First get our previously obtained OAuth2 access token.
oJsonToken := CreateObject("Chilkat.JsonObject")
nSuccess := oJsonToken: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

oHttp:SetUrlVar("access_token", oJsonToken:StringOf("access_token"))

oSbResponseBody := CreateObject("Chilkat.StringBuilder")
nSuccess := oHttp:QuickGetSb("https://api.mercadolibre.com/users/me?access_token={$access_token}", oSbResponseBody)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    oJsonToken:destroy()
    oSbResponseBody:destroy()
    RETURN
ENDIF

oJResp := CreateObject("Chilkat.JsonObject")
oJResp:LoadSb(oSbResponseBody)
oJResp:EmitCompact := 0

? "Response Body:"
? oJResp:Emit()

nRespStatusCode := oHttp:LastStatus
? "Response Status Code = " + Str(nRespStatusCode)
IF (nRespStatusCode >= 400)
    ? "Response Header:"
    ? oHttp:LastHeader
    ? "Failed."
    oHttp:destroy()
    oJsonToken:destroy()
    oSbResponseBody:destroy()
    oJResp:destroy()
    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

nId := oJResp:IntOf("id")
cNickname := oJResp:StringOf("nickname")
cRegistration_date := oJResp:StringOf("registration_date")
cCountry_id := oJResp:StringOf("country_id")
cAddressState := oJResp:StringOf("address.state")
cAddressCity := oJResp:StringOf("address.city")
cUser_type := oJResp:StringOf("user_type")
cLogo := oJResp:StringOf("logo")
nPoints := oJResp:IntOf("points")
cSite_id := oJResp:StringOf("site_id")
cPermalink := oJResp:StringOf("permalink")
cSeller_reputationLevel_id := oJResp:StringOf("seller_reputation.level_id")
cSeller_reputationPower_seller_status := oJResp:StringOf("seller_reputation.power_seller_status")
cSeller_reputationTransactionsPeriod := oJResp:StringOf("seller_reputation.transactions.period")
nSeller_reputationTransactionsTotal := oJResp:IntOf("seller_reputation.transactions.total")
nSeller_reputationTransactionsCompleted := oJResp:IntOf("seller_reputation.transactions.completed")
nSeller_reputationTransactionsCanceled := oJResp:IntOf("seller_reputation.transactions.canceled")
nSeller_reputationTransactionsRatingsPositive := oJResp:IntOf("seller_reputation.transactions.ratings.positive")
nSeller_reputationTransactionsRatingsNegative := oJResp:IntOf("seller_reputation.transactions.ratings.negative")
nSeller_reputationTransactionsRatingsNeutral := oJResp:IntOf("seller_reputation.transactions.ratings.neutral")
cStatusSite_status := oJResp:StringOf("status.site_status")
i := 0
nCount_i := oJResp:SizeOfArray("tags")
DO WHILE i < nCount_i
    oJResp:I := i
    cStrVal := oJResp:StringOf("tags[i]")
    i := i + 1
ENDDO
i := 0
nCount_i := oJResp:SizeOfArray("buyer_reputation.tags")
DO WHILE i < nCount_i
    oJResp:I := i
    i := i + 1
ENDDO

oHttp:destroy()
oJsonToken:destroy()
oSbResponseBody:destroy()
oJResp:destroy()