Posting to twitter from ColdFusion with Twitter4j v3.0.x

Author: Steven Neiland

Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.

Since writing my original article on integrating with twitter using the twitter4j library, twitter has updated their api and the twitter4j library was subsequently updated accordingly. Here is the new code for using twitter4j version 3.0.x.

<cfset cb = createObject("Java", "twitter4j.conf.ConfigurationBuilder") />

<cfset cb.setDebugEnabled(true)>
<cfset cb.setOAuthConsumerKey("yourconsumerkey")>
<cfset cb.setOAuthConsumerSecret("yourconsumersecret")>
<cfset cb.setOAuthAccessToken("youraccesstoken")>
<cfset cb.setOAuthAccessTokenSecret("youraccesstoken secret")>

<cfset twitterFactory = createObject("Java", "twitter4j.TwitterFactory").Init( />
<cfset twitter = twitterFactory.getInstance()>

<cfset status = twitter.updateStatus("test")>

Related Blog Postings

Reader Comments

Gilles Tanguay's Gravatar
Gilles Tanguay
Wednesday, October 7, 2015 at 3:29:55 PM Coordinated Universal Time


When I try a test post, I get this error:

Error Occurred While Processing Request PKIX path building failed: unable to find valid certification path to requested target

You can see it here:

Any hints??



  • Please keep comments on-topic.
  • Please do not post unrelated questions or large chunks of code.
  • Please do not engage in flaming/abusive behaviour.
  • Comments that contain advertisments or appear to be created for the purpose of link building, will not be published.

Archives Blog Listing