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

Author: Steven Neiland
Published:

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(cb.build()) />
<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

Hi,

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

Error Occurred While Processing Request
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

You can see it here:
http://www.emploifeep.com/tweet/

Any hints??

Thanks

Gilles

  • 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