Sample code for 30+ languages & platforms
Unicode C

Clickatell Send SMS Text Message using HTTP GET

See more Clickatell Examples

Demonstrate how to send a Clickatell SMS text message using an HTTP GET request with query params.

Chilkat Unicode C Downloads

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

void ChilkatSample(void)
    {
    BOOL success;
    HCkHttpW http;
    HCkJsonObjectW queryParams;
    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 -G https://api.clickatell.com/http/sendmsg \
    //   -d "api_id=xxxx" \
    //   -d "user=yourUsername" \
    //   -d "password=yourPassword" \
    //   -d "from=yourFromPhoneNumber" \
    //   -d "to=receiverPhoneNumber" \
    //   -d "text=The text of your message"

    // Use the following online tool to generate HTTP code from a CURL command
    // Convert a cURL Command to HTTP Source Code

    queryParams = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(queryParams,L"api_id",L"xxxx");
    CkJsonObjectW_UpdateString(queryParams,L"user",L"yourUsername");
    CkJsonObjectW_UpdateString(queryParams,L"password",L"yourPassword");
    CkJsonObjectW_UpdateString(queryParams,L"from",L"yourFromPhoneNumber");
    CkJsonObjectW_UpdateString(queryParams,L"to",L"receiverPhoneNumber");
    CkJsonObjectW_UpdateString(queryParams,L"text",L"The text of your message");

    // If the following URL does not work, then try "https://api.clickatell.com/http/sendmsg"
    resp = CkHttpResponseW_Create();
    success = CkHttpW_HttpParams(http,L"GET",L"https://platform.clickatell.com/messages/http/send",queryParams,resp);
    if (success == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(queryParams);
        CkHttpResponseW_Dispose(resp);
        return;
    }

    wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(queryParams);
    CkHttpResponseW_Dispose(resp);

    }