small medium large xlarge

Back to: All Forums  Arduino
Generic-user-small
14 Apr 2012, 01:51
James Dale (13 posts)

I was trying to get the Chapter 8 Twitter Temperature app but had trouble registering in on Twitter. All I could find was creating an app. I an not sure how to fill that out. Is there a different was to set it up now? Thank

Maik_schmidt_avatar2_pragsmall
15 Apr 2012, 07:35
Maik Schmidt (122 posts)

Hi James!

Do you have the ebook version of the book or a printed copy?

Twitter changed the registration process after the book went to print, but the latest ebook version of the Arduino book covers the new process.

Cheers, Maik

Generic-user-small
15 Apr 2012, 23:44
James Dale (13 posts)

I have have the print version 2011-7-28 P3.0 printing I figured out how to register but when I run the Processing pde I get an error on the line AccessToken accessToken = new AccessToken( The error is The type AccessToken is ambiguous

Thanks Jim

Maik_schmidt_avatar2_pragsmall
16 Apr 2012, 16:41
Maik Schmidt (122 posts)

Hi James!

What version of Processing do you use?

Can you post the code you’re trying to compile? (Remove your Twitter authentication tokens first!)

Cheers, Maik

Generic-user-small
18 Apr 2012, 01:59
James Dale (13 posts)

Here is is

// START:boilerplate import processing.serial.*;

final float MAX_WORKING_TEMP = 19.0; final int LINE_FEED = 10; final int BAUD_RATE = 9600; final String CONSUMER_KEY = final String CONSUMER_SECRET = final String ACCESS_TOKEN = final String ACCESS_TOKEN_SECRET = Serial arduinoPort;

void setup() { println(Serial.list()); arduinoPort = new Serial(this, Serial.list()[0], BAUD_RATE); arduinoPort.bufferUntil(LINE_FEED); }

void draw() {} // END:boilerplate

// START:main void serialEvent(Serial port) { final String arduinoData = port.readStringUntil(LINE_FEED);

if (arduinoData != null) { final String[] data = split(trim(arduinoData), ‘ ‘); if (data.length == 2 && (data[1].equals(“C”) || data[1].equals(“F”))) { float temperature = float(data[0]); println(temperature); int sleepTime = 5 * 60 * 1000; if (temperature > MAX_WORKING_TEMP) { tweetAlarm(); sleepTime = 120 * 60 * 1000; } try { Thread.sleep(sleepTime); } catch(InterruptedException ignoreMe) {} } } }

void tweetAlarm() { TwitterFactory factory = new TwitterFactory(); Twitter twitter = factory.getInstance(); twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);

This is the line that errors out

AccessToken accessToken = new AccessToken(

ACCESS_TOKEN, 
ACCESS_TOKEN_SECRET   );   twitter.setOAuthAccessToken(accessToken);   try {
Status status = twitter.updateStatus(
  "Someone, please, take me to the beach!"
);
println(
  "Successfully updated status to '" + status.getText() + "'."
);   }   catch (TwitterException e) {
e.printStackTrace();   } } // END:main

Thanks Jim D

Maik_schmidt_avatar2_pragsmall
18 Apr 2012, 06:04
Maik Schmidt (122 posts)

Hi James!

This is strange. I’ve compiled the code with the Processing IDE 1.5.1 some minutes ago and it works fine. Do you actually use the Processing IDE and not the Arduino IDE? What version of twitter4j do you use? I’ve used twitter4j-core-2.1.6-SNAPSHOT.jar and I’ve also tried the latest stable version 2.2.5.

Cheers, Maik

Generic-user-small
19 Apr 2012, 02:39
James Dale (13 posts)

I am using the Processing IDE. My Twitter is twitter4j-2.2.5

Maik_schmidt_avatar2_pragsmall
19 Apr 2012, 05:56
Maik Schmidt (122 posts)

I had a closer look at the code you’ve pasted above.

Does the erroneous line really look like this

@AccessToken accessToken = new AccessToken();@

or like this

@AccessToken accessToken = new AccessToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET);@

Generic-user-small
19 Apr 2012, 23:48
James Dale (13 posts)

This it the line that errors AccessToken accessToken = new AccessToken(

Generic-user-small
20 Apr 2012, 00:36
James Dale (13 posts)

I found the problem I had both the twitter4jXXX.jar files in the code folder. I left the SNAPSHOT.jar there and now it works. Thank Jim D

You must be logged in to comment