DataFlex
DataFlex
MercadoLibre - Consultar mis datos personales
See more MercadoLibre Examples
Consultar mis datos personalesChilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoHttp
Handle hoJsonToken
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
String sStrVal
Integer iId
String sNickname
String sRegistration_date
String sCountry_id
String sAddressState
String sAddressCity
String sUser_type
String sLogo
Integer iPoints
String sSite_id
String sPermalink
String sSeller_reputationLevel_id
String sSeller_reputationPower_seller_status
String sSeller_reputationTransactionsPeriod
Integer iSeller_reputationTransactionsTotal
Integer iSeller_reputationTransactionsCompleted
Integer iSeller_reputationTransactionsCanceled
Integer iSeller_reputationTransactionsRatingsPositive
Integer iSeller_reputationTransactionsRatingsNegative
Integer iSeller_reputationTransactionsRatingsNeutral
String sStatusSite_status
Integer i
Integer iCount_i
String sTemp1
Move False To iSuccess
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// First get our previously obtained OAuth2 access token.
Get Create (RefClass(cComChilkatJsonObject)) To hoJsonToken
If (Not(IsComObjectCreated(hoJsonToken))) Begin
Send CreateComObject of hoJsonToken
End
Get ComLoadFile Of hoJsonToken "qa_data/tokens/mercadolibre.json" To iSuccess
// 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
Get ComStringOf Of hoJsonToken "access_token" To sTemp1
Get ComSetUrlVar Of hoHttp "access_token" sTemp1 To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComQuickGetSb Of hoHttp "https://api.mercadolibre.com/users/me?access_token={$access_token}" vSbResponseBody To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJResp To False
Showln "Response Body:"
Get ComEmit Of hoJResp To sTemp1
Showln sTemp1
Get ComLastStatus Of hoHttp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComLastHeader Of hoHttp To sTemp1
Showln sTemp1
Showln "Failed."
Procedure_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
Get ComIntOf Of hoJResp "id" To iId
Get ComStringOf Of hoJResp "nickname" To sNickname
Get ComStringOf Of hoJResp "registration_date" To sRegistration_date
Get ComStringOf Of hoJResp "country_id" To sCountry_id
Get ComStringOf Of hoJResp "address.state" To sAddressState
Get ComStringOf Of hoJResp "address.city" To sAddressCity
Get ComStringOf Of hoJResp "user_type" To sUser_type
Get ComStringOf Of hoJResp "logo" To sLogo
Get ComIntOf Of hoJResp "points" To iPoints
Get ComStringOf Of hoJResp "site_id" To sSite_id
Get ComStringOf Of hoJResp "permalink" To sPermalink
Get ComStringOf Of hoJResp "seller_reputation.level_id" To sSeller_reputationLevel_id
Get ComStringOf Of hoJResp "seller_reputation.power_seller_status" To sSeller_reputationPower_seller_status
Get ComStringOf Of hoJResp "seller_reputation.transactions.period" To sSeller_reputationTransactionsPeriod
Get ComIntOf Of hoJResp "seller_reputation.transactions.total" To iSeller_reputationTransactionsTotal
Get ComIntOf Of hoJResp "seller_reputation.transactions.completed" To iSeller_reputationTransactionsCompleted
Get ComIntOf Of hoJResp "seller_reputation.transactions.canceled" To iSeller_reputationTransactionsCanceled
Get ComIntOf Of hoJResp "seller_reputation.transactions.ratings.positive" To iSeller_reputationTransactionsRatingsPositive
Get ComIntOf Of hoJResp "seller_reputation.transactions.ratings.negative" To iSeller_reputationTransactionsRatingsNegative
Get ComIntOf Of hoJResp "seller_reputation.transactions.ratings.neutral" To iSeller_reputationTransactionsRatingsNeutral
Get ComStringOf Of hoJResp "status.site_status" To sStatusSite_status
Move 0 To i
Get ComSizeOfArray Of hoJResp "tags" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "tags[i]" To sStrVal
Move (i + 1) To i
Loop
Move 0 To i
Get ComSizeOfArray Of hoJResp "buyer_reputation.tags" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Move (i + 1) To i
Loop
End_Procedure