Note that there are some explanatory texts on larger screens.

plurals
  1. POtwitter4j.auth.AccessToken instantiating in ColdFusion
    primarykey
    data
    text
    <p>I'm working with ColdFusion 9.0.1 and latest (for current date) stable build of twitter4j library - twitter4j-core-2.2.4. I'm trying to create functionality which allows users to login or register at our site using their twitter accounts. I was able to create authorization part: user click on the link on our site and system redirects him to twitter page. On this page he able to "Authorise" our application. After that system redirecting him back using callBackURL. But I have a problem with next step. When I'm trying to setOAuthAccessToken and for that trying to instantiate AccessToken object with follow part of code: </p> <pre><code>accessToken = createObject( 'java', 'twitter4j.auth.AccessToken' ).init( 'myStoredRequestToken', 'myStoredRequestTokenSecret' ); </code></pre> <p>But I have follow error: </p> <blockquote> <p>An exception occurred while instantiating a Java object. The class must not be an interface or an abstract class. Error: ''.</p> </blockquote> <p>Any ideas? </p> <p><strong>Update:</strong> </p> <p><em>The start part of stacktrace:</em></p> <p>'coldfusion.runtime.java.JavaObjectInstantiationException: Object instantiation exception. at coldfusion.runtime.java.JavaProxy.CreateObject(JavaProxy.java:171) at coldfusion.runtime.java.JavaProxy.invoke(JavaProxy.java:80) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2360) at cftwitter2ecfc2084917956$funcGETUSERCREDENTIALS.runFunction(C:\inetpub\wwwroot_test\twPlayGrnd_com\twitter.cfc:36) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55) at ... </p> <p><em>...cut here, not sure this is important...</em></p> <p><em>the last part is</em> </p> <p>cfapplication2ecfc665259542$funcONREQUEST.runFunction(C:\inetpub\wwwroot_test\twPlayGrnd\application.cfc:55) ... 55 more Caused by: java.lang.IllegalArgumentException: <em>Invalid access token format</em>. at twitter4j.auth.AccessToken.(AccessToken.java:50) ... 60 more'</p> <p><em>I saw the message about wrong format, but based on documentation at <a href="http://twitter4j.org" rel="nofollow">http://twitter4j.org</a> it should accept two agruments (strings with keys). Am I wrong?</em> </p> <p><strong>Update 2</strong> *<em>just find that out - I am sorry that I brought you into confusion with my first post and example... of course I used myStoredRequestToken, myStoredRequestTokenSecret, not a consumer key/secret *</em> *there are relevant parts of code I'm using for this functionality*</p> <p><strong>application.cfc</strong> <em>("onApplicationStart" function, instantiating components on start of application)</em></p> <pre><code>&lt;cffunction name="onApplicationStart" access="public" returntype="boolean" output="false"&gt; ... &lt;cfset application.com.twitterInstance = server.javaloader.create("twitter4j.TwitterFactory").getInstance() /&gt; &lt;cfset application.com.twitter = createObject("component","_com.twitter").init() /&gt; *&lt;!--- cfc component which will be listed below ---&gt;* ... &lt;/cffunction&gt; </code></pre> <p><strong>twitter.cfc</strong> <em>(corresponding coldfusion component)</em></p> <pre><code>&lt;cfcomponent displayname="twitter" output="false"&gt; &lt;cffunction name="init" access="public" output="false"&gt; &lt;cfreturn this&gt; &lt;/cffunction&gt; &lt;cffunction name="authorizeTwitter" access="public" output="false"&gt; &lt;cfargument name="callBackURL" type="string" required="false" default="#request.twtCallBackURL#" /&gt; &lt;cfset var requestToken = "" /&gt; &lt;cfset application.com.twitterInstance.setOAuthConsumer(request.twtConsumerKey,request.twtConsumerSecret) /&gt; &lt;cfset requestToken = application.com.twitterInstance.getOAuthRequestToken(arguments.callBackURL) /&gt; &lt;cflock scope="session" type="exclusive" timeout="10"&gt; &lt;cfset session.oAuthRequestToken = requestToken.getToken()&gt; &lt;cfset session.oAuthRequestTokenSecret = requestToken.getTokenSecret()&gt; &lt;/cflock&gt; &lt;cflocation url="#vLocal.requestToken.getAuthorizationURL()#" addtoken="No" /&gt; &lt;/cffunction&gt; &lt;cffunction name="getUserCredentials" access="public" output="true"&gt; &lt;cfset var vLocal = {} /&gt; &lt;cfset vLocal.accessToken = "" /&gt; &lt;cfset vLocal.userData = "" /&gt; &lt;cfset vLocal.requestToken = "" /&gt; &lt;cfset vLocal.accessToken = server.javaloader.create("twitter4j.auth.AccessToken").init(session.oAuthRequestToken,session.oAuthRequestTokenSecret)&gt; &lt;cfset application.com.twitterInstance.setOAuthAccessToken(vLocal.accessToken) /&gt; &lt;cfset vLocal.userData = application.com.twitterInstance.verifyCredentials() /&gt; &lt;cfdump var="#vLocal.userData#" label="User Credentials"&gt; &lt;/cffunction&gt; </code></pre> <p><em>First function is for first step - requesting twitter for autorization page (where user can autorize or deny application). Call back URL runs the page what calls the second function and I have problem only at this step (line for generation accessToken).</em> </p> <p><em>I have the same result if Im using createObject function instead of javaloader.</em> </p> <p>*So, my main question is still the same - to obtain the users unique Access Token? Please point me, what I'm doing wrong? What is a correct format for unique user's accessToken generation? Should I place oauth_verifier parameter there? if so, how?*</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload