The Twitter4J code I've gotten to work forces the user to click
“Allow” on the Twitter authorization page (An application would like
to connect to your account), every time the code is run. Any ideas on
how the flow can be changed so that anytime a user goes through the
Authentication Process, if the user has already authorized the APP the
user is not required to visit Twitter again and click “Allow” every
time but is simply sent back to my web app?

My Code:
<cfset Twitter = createObject("java", "twitter4j.Twitter")>
<cfset Twitter.setOAuthConsumer('XXXXXXX','XXXXXX')>
<cfparam name="URL.oauth_token" type="string" default="">

<cfif URL.oauth_token EQ "">STEP1

       <cfset RequestToken = Twitter.getOAuthRequestToken()>
       <cfset Session.oAuthRequestToken = RequestToken.getToken()>
       <cfset Session.oAuthRequestTokenSecret =
RequestToken.getTokenSecret()>

       <cflocation url="#RequestToken.getAuthorizationURL()#"
addtoken="No">

       <!--- At this point, the user is on TwitterÕs site and have the
opportunity to Allow or Deny access. --->
       <!--- Twitter will now send back to HERE when the USER
autorhizes you --->

<cfelse>STEP2<BR>
       <!--- After Allowing access, the user is transferred back to
your site and you exchange the Request Tokens for Access Tokens: --->

       <cfset AccessToken = Twitter.getOAuthAccessToken
(Session.oAuthRequestToken,Session.oAuthRequestTokenSecret)>
       <!--- Store the Access Tokens, via: AccessToken.getToken() and
AccessToken.getTokenSecret() --->

       <cfoutput>
       AccessToken:#AccessToken#
       AccessToken.getToken(): #AccessToken.getToken()#<br>
       Session.oAuthRequestTokenSecret:
#Session.oAuthRequestTokenSecret#
       </cfoutput>

       <!--- Test Twitter API access --->
       <!---   <cfset Twitter.setOAuthAccessToken
(StoredAccessToken,StoredAccessSecret)> --->
                       <cfset Twitter.setOAuthAccessToken
(#AccessToken.getToken()#,#AccessToken.getTokenSecret()#)>
                       <cfset Twitter.updateStatus("Testing 1.2.3.4..")
>

</cfif>

Reply via email to