PowerBuilder
PowerBuilder
MercadoLibre - Consultar mis datos personales
See more MercadoLibre Examples
Consultar mis datos personalesChilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_JsonToken
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_StrVal
integer li_Id
string ls_Nickname
string ls_Registration_date
string ls_Country_id
string ls_AddressState
string ls_AddressCity
string ls_User_type
string ls_Logo
integer li_Points
string ls_Site_id
string ls_Permalink
string ls_Seller_reputationLevel_id
string ls_Seller_reputationPower_seller_status
string ls_Seller_reputationTransactionsPeriod
integer li_Seller_reputationTransactionsTotal
integer li_Seller_reputationTransactionsCompleted
integer li_Seller_reputationTransactionsCanceled
integer li_Seller_reputationTransactionsRatingsPositive
integer li_Seller_reputationTransactionsRatingsNegative
integer li_Seller_reputationTransactionsRatingsNeutral
string ls_StatusSite_status
integer i
integer li_Count_i
li_Success = 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
// First get our previously obtained OAuth2 access token.
loo_JsonToken = create oleobject
li_rc = loo_JsonToken.ConnectToNewObject("Chilkat.JsonObject")
li_Success = loo_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
loo_Http.SetUrlVar("access_token",loo_JsonToken.StringOf("access_token"))
loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
li_Success = loo_Http.QuickGetSb("https://api.mercadolibre.com/users/me?access_token={$access_token}",loo_SbResponseBody)
if li_Success = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_JsonToken
destroy loo_SbResponseBody
return
end if
loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")
loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0
Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()
li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Http.LastHeader
Write-Debug "Failed."
destroy loo_Http
destroy loo_JsonToken
destroy loo_SbResponseBody
destroy loo_JResp
return
end if
// 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
li_Id = loo_JResp.IntOf("id")
ls_Nickname = loo_JResp.StringOf("nickname")
ls_Registration_date = loo_JResp.StringOf("registration_date")
ls_Country_id = loo_JResp.StringOf("country_id")
ls_AddressState = loo_JResp.StringOf("address.state")
ls_AddressCity = loo_JResp.StringOf("address.city")
ls_User_type = loo_JResp.StringOf("user_type")
ls_Logo = loo_JResp.StringOf("logo")
li_Points = loo_JResp.IntOf("points")
ls_Site_id = loo_JResp.StringOf("site_id")
ls_Permalink = loo_JResp.StringOf("permalink")
ls_Seller_reputationLevel_id = loo_JResp.StringOf("seller_reputation.level_id")
ls_Seller_reputationPower_seller_status = loo_JResp.StringOf("seller_reputation.power_seller_status")
ls_Seller_reputationTransactionsPeriod = loo_JResp.StringOf("seller_reputation.transactions.period")
li_Seller_reputationTransactionsTotal = loo_JResp.IntOf("seller_reputation.transactions.total")
li_Seller_reputationTransactionsCompleted = loo_JResp.IntOf("seller_reputation.transactions.completed")
li_Seller_reputationTransactionsCanceled = loo_JResp.IntOf("seller_reputation.transactions.canceled")
li_Seller_reputationTransactionsRatingsPositive = loo_JResp.IntOf("seller_reputation.transactions.ratings.positive")
li_Seller_reputationTransactionsRatingsNegative = loo_JResp.IntOf("seller_reputation.transactions.ratings.negative")
li_Seller_reputationTransactionsRatingsNeutral = loo_JResp.IntOf("seller_reputation.transactions.ratings.neutral")
ls_StatusSite_status = loo_JResp.StringOf("status.site_status")
i = 0
li_Count_i = loo_JResp.SizeOfArray("tags")
do while i < li_Count_i
loo_JResp.I = i
ls_StrVal = loo_JResp.StringOf("tags[i]")
i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("buyer_reputation.tags")
do while i < li_Count_i
loo_JResp.I = i
i = i + 1
loop
destroy loo_Http
destroy loo_JsonToken
destroy loo_SbResponseBody
destroy loo_JResp