![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java JavaScript 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
(Visual FoxPro) Twitter PIN-Based Authorization (Step 2)Demonstrates the 2nd step in Twitter PIN-based authorization using OAuth. A PIN should have already been obtained from Step 1. The PIN is the OAuth verifier used in combination with the consumer secret and consumer key to get the access token and token secret that will be used for subsequent Twitter requests (to do whatever the Twitter account owner has permitted your application to do..) Note: This example requires Chilkat v11.0.0 or greater.
LOCAL lnSuccess LOCAL loHttp LOCAL loReq LOCAL loResp LOCAL lcOauthToken LOCAL lcOauthTokenSecret lnSuccess = 0 * This example requires the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. loHttp = CreateObject('Chilkat.Http') loHttp.OAuth1 = 1 loHttp.OAuthConsumerKey = "my-consumer-key" loHttp.OAuthConsumerSecret = "my-consumer-secret" loHttp.OAuthVerifier = "the-PIN-obtained-from-Step1" loReq = CreateObject('Chilkat.HttpRequest') loReq.HttpVerb = "POST" loReq.ContentType = "application/x-www-form-urlencoded" loResp = CreateObject('Chilkat.HttpResponse') lnSuccess = loHttp.HttpReq("https://api.twitter.com/oauth/access_token",loReq,loResp) IF (lnSuccess = 0) THEN ? loHttp.LastErrorText RELEASE loHttp RELEASE loReq RELEASE loResp CANCEL ENDIF IF (loResp.StatusCode = 200) THEN * Get the access token and secret: lcOauthToken = loResp.UrlEncParamValue(loResp.BodyStr,"oauth_token") ? "Access token = " + lcOauthToken lcOauthTokenSecret = loResp.UrlEncParamValue(loResp.BodyStr,"oauth_token_secret") ? "Token secret = " + lcOauthTokenSecret * Your application may now perform operations on the * Twitter account for whatever has been authorized. * To do so, prior to sending the HTTP request, * set the OAuthToken and OAuthTokenSecret * properties, and also make sure to clear OAuthVerifier property: loHttp.OAuthToken = lcOauthToken loHttp.OAuthTokenSecret = lcOauthTokenSecret loHttp.OAuthVerifier = "" * Now that the http object has valid property values * for OAuthConsumerKey, OAuthConsumerSecret, * OAuthToken, and OAuthTokenSecret, it can send authenticated * Twitter requests to the user's Twitter account. ELSE ? loHttp.LastErrorText ENDIF RELEASE loHttp RELEASE loReq RELEASE loResp |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.