(Unicode C) Example: Http.QuickGetStr method
Demonstrates the QuickGetStr method.
#include <C_CkHttpW.h>
void ChilkatSample(void)
{
HCkHttpW http;
const wchar_t *str;
http = CkHttpW_Create();
// Keep the response body if there's an error.
CkHttpW_putKeepResponseBody(http,TRUE);
// Send the HTTP GET and return the content in a string.
str = CkHttpW_quickGetStr(http,L"https://www.chilkatsoft.com/helloWorld.json");
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
if (CkHttpW_getLastStatus(http) == 0) {
// Communications error. We did not get a response.
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
}
else {
wprintf(L"Response status code: %d\n",CkHttpW_getLastStatus(http));
wprintf(L"Response body error text:\n");
wprintf(L"%s\n",CkHttpW_lastResponseBody(http));
}
CkHttpW_Dispose(http);
return;
}
wprintf(L"%s\n",str);
wprintf(L"Success\n");
CkHttpW_Dispose(http);
}
|