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
(Perl) Twitter PIN-Based Authorization (Step 1)Demonstrates the 1st step in Twitter PIN-based authorization using OAuth. The purpose of this step is to obtain a temporary request token that will be traded for an access token + secret in the final step. Once the access token + secret is obtained, the application can access the Twitter account in whatever ways it was authorized. Note: The OAuth version 1 functionality demonstrated in this example is available in Chilkat v9.4.0 to be released approximately in mid-December 2012. Pre-releases are available upon request by sending email to support@chilkatsoft.com. (Please be sure to specify your programming language, operating system, framework, architecture, etc. to uniquely identify the build that is needed.)
use chilkat(); # This example requires the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. $http = chilkat::CkHttp->new(); $http->put_OAuth1(1); $http->put_OAuthConsumerKey("my-consumer-key"); $http->put_OAuthConsumerSecret("my-consumer-secret"); $req = chilkat::CkHttpRequest->new(); # resp is a HttpResponse $resp = $http->PostUrlEncoded("https://api.twitter.com/oauth/request_token",$req); if ($http->get_LastMethodSuccess() == 0) { print $http->lastErrorText() . "\r\n"; exit; } if ($resp->get_StatusCode() == 200) { $oauthToken = $resp->urlEncParamValue($resp->bodyStr(),"oauth_token"); print "OAuth temporary request token = " . $oauthToken . "\r\n"; $oauthTokenSecret = $resp->urlEncParamValue($resp->bodyStr(),"oauth_token_secret"); print "OAuth temporary token secret = " . $oauthTokenSecret . "\r\n"; $oauthCbConfirmed = $resp->urlEncParamValue($resp->bodyStr(),"oauth_callback_confirmed"); print "OAuth callback confirmed = " . $oauthCbConfirmed . "\r\n"; # At this point, the end-user needs to browse to the following # Twitter URL to log in to his/her Twitter account and get a PIN. # # https://api.twitter.com/oauth/authenticate?oauth_token=OAUTH_TOKEN # # (where OAUTH_TOKEN is replaced with the contents # of the OAuth temporary request token.) # Your application may have an embedded browser such # that it automatically navigates to the above URL, or it may # be necessary for the user to browse to this URL independently. # Once the PIN is obtained, your application should provide a means # for the end-user to enter it (by typing it into an input text box, for example), # and then Step 2 (the final step) can begin. } else { print $http->lastErrorText() . "\r\n"; } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.