Classic ASP
Classic ASP
WhatsApp - Get a User's Account Information
Demonstrates how to retrieve a user account by sending a GET request on the users endpoint.Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
set http = Server.CreateObject("Chilkat.Http")
' 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"
set sbResponseBody = Server.CreateObject("Chilkat.StringBuilder")
success = http.QuickGetSb("https://example.com/v1/users/username",sbResponseBody)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"
Response.End
End If
set jResp = Server.CreateObject("Chilkat.JsonObject")
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = 0
Response.Write "<pre>" & Server.HTMLEncode( "Response Body:") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( jResp.Emit()) & "</pre>"
respStatusCode = http.LastStatus
Response.Write "<pre>" & Server.HTMLEncode( "Response Status Code = " & respStatusCode) & "</pre>"
If (respStatusCode >= 400) Then
Response.Write "<pre>" & Server.HTMLEncode( "Response Header:") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( http.LastHeader) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Failed.") & "</pre>"
Response.End
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...
i = 0
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
%>
</body>
</html>