Sample code for 30+ languages & platforms
Visual Basic 6.0

WhatsApp - Get a User's Account Information

Demonstrates how to retrieve a user account by sending a GET request on the users endpoint.

Chilkat Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

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

Dim http As New ChilkatHttp

' Implements the following CURL command:

' curl -X GET https://example.com/v1/users/username \
'   -H "Authorization: Bearer your-auth-token"

' Adds the "Authorization: Bearer your-auth-token" header.
http.AuthToken = "your-auth-token"

Dim sbResponseBody As New ChilkatStringBuilder
success = http.QuickGetSb("https://example.com/v1/users/username",sbResponseBody)
If (success = 0) Then
    Debug.Print http.LastErrorText
    Exit Sub
End If

Dim jResp As New ChilkatJsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = 0

Debug.Print "Response Body:"
Debug.Print jResp.Emit()

Dim respStatusCode As Long
respStatusCode = http.LastStatus
Debug.Print "Response Status Code = " & respStatusCode
If (respStatusCode >= 400) Then
    Debug.Print "Response Header:"
    Debug.Print http.LastHeader
    Debug.Print "Failed."
    Exit Sub
End If

' Sample JSON response:
' (Sample code for parsing the JSON response is shown below)

' {
'   "users": [
'     {
'       "ROLES": "ROLE_ADMIN | ROLE_USER",
'       "username": "username"
'     }
'   ]
' }

' Sample code for parsing the JSON response...

Dim ROLES As String
Dim username As String

Dim i As Long
i = 0
Dim count_i As Long
count_i = jResp.SizeOfArray("users")
Do While i < count_i
    jResp.I = i
    ROLES = jResp.StringOf("users[i].ROLES")
    username = jResp.StringOf("users[i].username")
    i = i + 1
Loop