(C) WhatsApp - Logout
Demonstrates the /v1/users/logout endpoint to logout of the WhatsApp Business API Client. Logging out revokes the authentication token. Note: This example requires Chilkat v11.0.0 or greater. For more information, see https://developers.facebook.com/docs/whatsapp/api/users/logout
#include <C_CkHttp.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttp http;
HCkHttpResponse resp;
success = FALSE;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
// 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.
CkHttp_putAuthToken(http,"your-auth-token");
resp = CkHttpResponse_Create();
success = CkHttp_HttpNoBody(http,"POST","https://your-webapp-hostname:your-webapp-port/v1/users/logout",resp);
if (success == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkHttpResponse_Dispose(resp);
return;
}
printf("Response body:\n");
printf("%s\n",CkHttpResponse_bodyStr(resp));
CkHttp_Dispose(http);
CkHttpResponse_Dispose(resp);
}
|