Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kasperkamperman/337763c308523f2f7a59800de7873b35 to your computer and use it in GitHub Desktop.
Save kasperkamperman/337763c308523f2f7a59800de7873b35 to your computer and use it in GitHub Desktop.
The Temboo Save To Spreadsheet tutorial example (https://temboo.com/processing/save-to-spreadsheet) has an error, this example corrects it:
/* FIX for Temboo Save Mouse Click position tutorial
https://temboo.com/processing/save-to-spreadsheet
The example given doesn't work because it's missing the ClientId, ClientSecret and the RefreshToken
I've added them in this example below.
See appendRow for all the things you can add (the fields you can fill in):
https://temboo.com/library/Library/Google/Spreadsheets/AppendRow/
Of course you have to fill in your own credentials. To obtain them, just follow the tutorial steps.
Step 4 of the tutorial could also be more clear. From the Create Credentials pull down you have to
select: OAuth client ID. Then you can specify Web application.
*/
import com.temboo.core.*;
import com.temboo.Library.Google.Spreadsheets.*;
// Create a session using your Temboo account application details
TembooSession session = new TembooSession("kasperkamperman", "test", "vlJZXLWXwKwW2I6gd3ulJvqa7YkGavgR");
// The name of your Temboo Google Profile
String googleProfile = "tembooTestSheets";
// Declare global variables that will be saved to spreadsheet
int xPos, yPos;
String currentTime;
// Set up color and size of click circles
color clickColor = color(0, 255, 0);
color saveColor = color(255, 0, 0);
int circleSize = 8;
void setup() {
size(400, 400);
}
void draw() {
}
void mousePressed() {
// Change cursor to wait
cursor(WAIT);
// Get x and y position values of click
xPos = mouseX;
yPos = mouseY;
// Draw circle where click occurred
fill(clickColor);
ellipse(xPos, yPos, circleSize, circleSize);
}
void mouseReleased() {
// Write an in-progress message to console
println("Writing to your Google Spreadsheet...");
// Get current time
currentTime = year()+"/"+month()+"/"+day()+" "+hour()+":"+minute()+":"+second()+"."+millis();
// Run the AppendRow Choreo function
runAppendRowChoreo();
// Draw finished circle
fill(saveColor);
ellipse(xPos, yPos, circleSize, circleSize);
// Write a finished message to console
println("done!");
// Change cursor back to normal
cursor(ARROW);
}
void runAppendRowChoreo() {
// Create the Choreo object using your Temboo session
AppendRow appendRowChoreo = new AppendRow(session);
// Set Profile
// This doesn't work only and doesn't do anything...
//appendRowChoreo.setCredential(googleProfile);
// WE NEED TO SET HERE ALL THE CREDITIONALS
appendRowChoreo.setClientID("YOUR_CLIENT_ID");
appendRowChoreo.setClientSecret("YOUR_CLIENT_SECRET");
appendRowChoreo.setRefreshToken("YOUR_REFRESH_TOKEN");
// Set inputs
appendRowChoreo.setRowData(currentTime + "," + str(mouseX) + "," + str(mouseY));
appendRowChoreo.setSpreadsheetTitle("mouseClicks");
// Run the Choreo and store the results
AppendRowResultSet appendRowResults = appendRowChoreo.run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment