![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(C) X.com Verfiy Credentials (Deprecated OAuth 1.0a Authentication)See more X ExamplesThis is a simple API call to verify that OAuth1.0a authorization is working.Returns an HTTP 200 OK response code and a representation of the requesting user if authentication was successful; returns a 401 status code and an error message if not. Use this method to test if supplied user credentials are valid. X.com historically used OAuth 1.0a for authenticating API requests. However, as of April 2023, Twitter has deprecated OAuth 1.0a and migrated to OAuth 2.0 for most of its API endpoints. This change was part of Twitter's effort to modernize its API and improve security. That said, if you're working with a legacy system or have access to older documentation, you might still encounter references to OAuth 1.0a. This example shows how Chilkat could be used with the older/deprecated Twitter v1.1 API calls. For more information, see https://developer.x.com/en/docs/x-api/v1/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials
#include <C_CkHttp.h> #include <C_CkStringBuilder.h> #include <C_CkJsonObject.h> void ChilkatSample(void) { HCkHttp http; HCkStringBuilder sbResponse; BOOL success; int statusCode; HCkJsonObject json; http = CkHttp_Create(); // Indicate OAuth1.0a authentication is to be used with HTTP requests. CkHttp_putOAuth1(http,TRUE); // Provide OAuth1.0a credentials CkHttp_putOAuthConsumerKey(http,"X_API_KEY"); CkHttp_putOAuthConsumerSecret(http,"X_API_SECRET"); CkHttp_putOAuthSigMethod(http,"HMAC-SHA1"); CkHttp_putOAuthToken(http,"X_ACCESS_TOKEN"); CkHttp_putOAuthTokenSecret(http,"X_TOKEN_SECRET"); CkHttp_putOAuthVerifier(http,""); sbResponse = CkStringBuilder_Create(); success = CkHttp_QuickGetSb(http,"https://api.twitter.com/1.1/account/verify_credentials.json",sbResponse); if (success == FALSE) { printf("%s\n",CkHttp_lastErrorText(http)); CkHttp_Dispose(http); CkStringBuilder_Dispose(sbResponse); return; } statusCode = CkHttp_getLastStatus(http); if (statusCode != 200) { printf("%s\n",CkHttp_lastErrorText(http)); CkHttp_Dispose(http); CkStringBuilder_Dispose(sbResponse); return; } // We received a successful JSON response. json = CkJsonObject_Create(); CkJsonObject_LoadSb(json,sbResponse); CkJsonObject_putEmitCompact(json,FALSE); printf("%s\n",CkJsonObject_emit(json)); CkHttp_Dispose(http); CkStringBuilder_Dispose(sbResponse); CkJsonObject_Dispose(json); } |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.