![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Tcl) WhatsApp - Get a User's Account InformationDemonstrates how to retrieve a user account by sending a GET request on the users endpoint. For more information, see https://developers.facebook.com/docs/whatsapp/api/users/manage
load ./chilkat.dll # This example assumes the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set http [new_CkHttp] # 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. CkHttp_put_AuthToken $http "your-auth-token" set sbResponseBody [new_CkStringBuilder] set success [CkHttp_QuickGetSb $http "https://example.com/v1/users/username" $sbResponseBody] if {$success == 0} then { puts [CkHttp_lastErrorText $http] delete_CkHttp $http delete_CkStringBuilder $sbResponseBody exit } set jResp [new_CkJsonObject] CkJsonObject_LoadSb $jResp $sbResponseBody CkJsonObject_put_EmitCompact $jResp 0 puts "Response Body:" puts [CkJsonObject_emit $jResp] set respStatusCode [CkHttp_get_LastStatus $http] puts "Response Status Code = $respStatusCode" if {$respStatusCode >= 400} then { puts "Response Header:" puts [CkHttp_lastHeader $http] puts "Failed." delete_CkHttp $http delete_CkStringBuilder $sbResponseBody delete_CkJsonObject $jResp exit } # 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... set i 0 set count_i [CkJsonObject_SizeOfArray $jResp "users"] while {$i < $count_i} { CkJsonObject_put_I $jResp $i set ROLES [CkJsonObject_stringOf $jResp "users[i].ROLES"] set username [CkJsonObject_stringOf $jResp "users[i].username"] set i [expr $i + 1] } delete_CkHttp $http delete_CkStringBuilder $sbResponseBody delete_CkJsonObject $jResp |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.