(Swift) WhatsApp - Logout
Demonstrates the /v1/users/logout endpoint to logout of the WhatsApp Business API Client. Logging out revokes the authentication token. For more information, see https://developers.facebook.com/docs/whatsapp/api/users/logout
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
var success: Bool
// Implements the following CURL command:
// curl -X POST https://your-webapp-hostname:your-webapp-port/v1/users/logout \
// -H "Authorization: Bearer your-auth-token"
// Adds the "Authorization: Bearer your-auth-token" header.
http.authToken = "your-auth-token"
var resp: CkoHttpResponse? = http.quickRequest("POST", url: "https://your-webapp-hostname:your-webapp-port/v1/users/logout")
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
print("Response body:")
print("\(resp!.bodyStr!)")
}
|