AutoIt
AutoIt
MercadoLibre - Consultar mis datos personales
See more MercadoLibre Examples
Consultar mis datos personalesChilkat AutoIt Downloads
Local $bSuccess = False
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
; First get our previously obtained OAuth2 access token.
$oJsonToken = ObjCreate("Chilkat.JsonObject")
$bSuccess = $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 = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oHttp.QuickGetSb("https://api.mercadolibre.com/users/me?access_token={$access_token}",$oSbResponseBody)
If ($bSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False
ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)
Local $iRespStatusCode = $oHttp.LastStatus
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
ConsoleWrite("Response Header:" & @CRLF)
ConsoleWrite($oHttp.LastHeader & @CRLF)
ConsoleWrite("Failed." & @CRLF)
Exit
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
Local $strVal
Local $id = $oJResp.IntOf("id")
Local $sNickname = $oJResp.StringOf("nickname")
Local $sRegistration_date = $oJResp.StringOf("registration_date")
Local $sCountry_id = $oJResp.StringOf("country_id")
Local $sAddressState = $oJResp.StringOf("address.state")
Local $sAddressCity = $oJResp.StringOf("address.city")
Local $sUser_type = $oJResp.StringOf("user_type")
Local $sLogo = $oJResp.StringOf("logo")
Local $iPoints = $oJResp.IntOf("points")
Local $site_id = $oJResp.StringOf("site_id")
Local $sPermalink = $oJResp.StringOf("permalink")
Local $seller_reputationLevel_id = $oJResp.StringOf("seller_reputation.level_id")
Local $seller_reputationPower_seller_status = $oJResp.StringOf("seller_reputation.power_seller_status")
Local $seller_reputationTransactionsPeriod = $oJResp.StringOf("seller_reputation.transactions.period")
Local $iSeller_reputationTransactionsTotal = $oJResp.IntOf("seller_reputation.transactions.total")
Local $iSeller_reputationTransactionsCompleted = $oJResp.IntOf("seller_reputation.transactions.completed")
Local $iSeller_reputationTransactionsCanceled = $oJResp.IntOf("seller_reputation.transactions.canceled")
Local $iSeller_reputationTransactionsRatingsPositive = $oJResp.IntOf("seller_reputation.transactions.ratings.positive")
Local $iSeller_reputationTransactionsRatingsNegative = $oJResp.IntOf("seller_reputation.transactions.ratings.negative")
Local $iSeller_reputationTransactionsRatingsNeutral = $oJResp.IntOf("seller_reputation.transactions.ratings.neutral")
Local $statusSite_status = $oJResp.StringOf("status.site_status")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("tags")
While $i < $iCount_i
$oJResp.I = $i
$strVal = $oJResp.StringOf("tags[i]")
$i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("buyer_reputation.tags")
While $i < $iCount_i
$oJResp.I = $i
$i = $i + 1
Wend