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) Twitter OAuth -- Tweet to Your Own AccountDemonstrates how to send a tweet (status update) to your own Twitter account using pre-known credentials, which includes:
#include <C_CkHttpW.h> #include <C_CkHttpRequestW.h> #include <C_CkHttpResponseW.h> void ChilkatSample(void) { HCkHttpW http; HCkHttpRequestW req; HCkHttpResponseW resp; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttpW_Create(); CkHttpW_putOAuth1(http,TRUE); CkHttpW_putOAuthVerifier(http,L""); CkHttpW_putOAuthConsumerKey(http,L"my-consumer-key"); CkHttpW_putOAuthConsumerSecret(http,L"my-consumer-secret"); CkHttpW_putOAuthToken(http,L"my-access-token"); CkHttpW_putOAuthTokenSecret(http,L"my-token-secret"); // Send the same status update as shown in this example: // https://dev.twitter.com/docs/api/1.1/post/statuses/update // IMPORTANT: Make sure this app has read/write access. // Otherwise it cannot post an update (i.e. tweet) to the Twitter account. req = CkHttpRequestW_Create(); CkHttpRequestW_AddParam(req,L"status",L"Maybe he'll finally find his keys. #peterfalk"); resp = CkHttpW_PostUrlEncoded(http,L"https://api.twitter.com/1.1/statuses/update.json",req); if (CkHttpW_getLastMethodSuccess(http) != TRUE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkHttpRequestW_Dispose(req); return; } if (CkHttpResponseW_getStatusCode(resp) == 200) { // Display the JSON response. wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp)); } else { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); } CkHttpResponseW_Dispose(resp); CkHttpW_Dispose(http); CkHttpRequestW_Dispose(req); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.