Delphi DLL
Delphi DLL
SimpleTexting - Check Remaining Credits
See more SimpleTexting Examples
Retrieve your remaining credit balance for the current billing cycle.Chilkat Delphi DLL Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Http, StringBuilder, JsonObject;
...
procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
http: HCkHttp;
sbResponseBody: HCkStringBuilder;
jResp: HCkJsonObject;
respStatusCode: Integer;
code: Integer;
message: PWideChar;
messagesCount: Integer;
begin
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 --request GET \
// --url 'https://app2.simpletexting.com/v1/messaging/check?token=YOUR_API_TOKEN' \
// --header 'accept: application/json'
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
CkHttp_SetRequestHeader(http,'accept','application/json');
sbResponseBody := CkStringBuilder_Create();
success := CkHttp_QuickGetSb(http,'https://app2.simpletexting.com/v1/messaging/check?token=YOUR_API_TOKEN',sbResponseBody);
if (success = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
jResp := CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,False);
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkJsonObject__emit(jResp));
respStatusCode := CkHttp_getLastStatus(http);
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
begin
Memo1.Lines.Add('Response Header:');
Memo1.Lines.Add(CkHttp__lastHeader(http));
Memo1.Lines.Add('Failed.');
Exit;
end;
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "code": 1,
// "message": "The request succeeded",
// "messagesCount": 2989
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
code := CkJsonObject_IntOf(jResp,'code');
message := CkJsonObject__stringOf(jResp,'message');
messagesCount := CkJsonObject_IntOf(jResp,'messagesCount');
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
end;