Sample code for 30+ languages & platforms
Unicode C

WhatsApp - Logout

Demonstrates the /v1/users/logout endpoint to logout of the WhatsApp Business API Client. Logging out revokes the authentication token.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkHttpW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkHttpW http;
    HCkHttpResponseW resp;

    success = FALSE;

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

    http = CkHttpW_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.
    CkHttpW_putAuthToken(http,L"your-auth-token");

    resp = CkHttpResponseW_Create();
    success = CkHttpW_HttpNoBody(http,L"POST",L"https://your-webapp-hostname:your-webapp-port/v1/users/logout",resp);
    if (success == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkHttpResponseW_Dispose(resp);
        return;
    }

    wprintf(L"Response body:\n");
    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));


    CkHttpW_Dispose(http);
    CkHttpResponseW_Dispose(resp);

    }