Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C) Dropbox: Get Space UsageDemonstrates how to get the Dropbox space usage information for the current user's account. For more information, see https://www.dropbox.com/developers/documentation/http/documentation#users-get_space_usage
#include <C_CkRestW.h> #include <C_CkJsonObjectW.h> void ChilkatSample(void) { HCkRestW rest; BOOL bTls; int port; BOOL bAutoReconnect; BOOL success; const wchar_t *responseStr; HCkJsonObjectW jsonResponse; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. rest = CkRestW_Create(); // Connect to the www.dropbox.com endpoint. bTls = TRUE; port = 443; bAutoReconnect = TRUE; success = CkRestW_Connect(rest,L"api.dropboxapi.com",port,bTls,bAutoReconnect); if (success != TRUE) { wprintf(L"%s\n",CkRestW_lastErrorText(rest)); CkRestW_Dispose(rest); return; } CkRestW_AddHeader(rest,L"Authorization",L"Bearer DROPBOX-ACCESS-TOKEN"); responseStr = CkRestW_fullRequestNoBody(rest,L"POST",L"/2/users/get_space_usage"); if (CkRestW_getLastMethodSuccess(rest) != TRUE) { wprintf(L"%s\n",CkRestW_lastErrorText(rest)); CkRestW_Dispose(rest); return; } // Success is indicated by a 200 response status code. if (CkRestW_getResponseStatusCode(rest) != 200) { // Examine the request/response to see what happened. wprintf(L"response status code = %d\n",CkRestW_getResponseStatusCode(rest)); wprintf(L"response status text = %s\n",CkRestW_responseStatusText(rest)); wprintf(L"response header: %s\n",CkRestW_responseHeader(rest)); wprintf(L"response body (if any): %s\n",responseStr); wprintf(L"---\n"); wprintf(L"LastRequestStartLine: %s\n",CkRestW_lastRequestStartLine(rest)); wprintf(L"LastRequestHeader: %s\n",CkRestW_lastRequestHeader(rest)); CkRestW_Dispose(rest); return; } jsonResponse = CkJsonObjectW_Create(); CkJsonObjectW_Load(jsonResponse,responseStr); CkJsonObjectW_putEmitCompact(jsonResponse,FALSE); wprintf(L"%s\n",CkJsonObjectW_emit(jsonResponse)); // { // "used": 3032115, // "allocation": { // ".tag": "individual", // "allocated": 2147483648 // } // } // CkRestW_Dispose(rest); CkJsonObjectW_Dispose(jsonResponse); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.