From acf38a634ab0f5530ca5f0b15bc4c474b1091195 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Mon, 8 Jul 2013 15:09:09 +0200 Subject: updated temboo examples --- .../examples/Temboo/SendAnEmail/SendAnEmail.ino | 55 +++++++++------------- .../examples/Temboo/SendAnEmail/TembooAccount.h | 1 - 2 files changed, 21 insertions(+), 35 deletions(-) (limited to 'libraries/Bridge/examples/Temboo/SendAnEmail') diff --git a/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino b/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino index 1ed95df..a602cc1 100644 --- a/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino +++ b/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino @@ -22,10 +22,7 @@ */ #include -#include -#include -#include -#include +#include #include "TembooAccount.h" // contains Temboo account information // as described in the footer comment below @@ -34,7 +31,7 @@ // Note that for additional security and reusability, you could // use #define statements to specify these values in a .h file. -// your Gmail address, eg "bob.smith@gmail.com" +// your Gmail username, formatted as a complete email address, eg "bob.smith@gmail.com" const String GMAIL_USER_NAME = "xxxxxxxxxx"; // your Gmail password @@ -62,50 +59,40 @@ void loop() if (!success) { Serial.println("Running SendAnEmail..."); - - // we need a Process object to send a Choreo request to Temboo - Process SendEmailChoreo; + + TembooChoreo SendEmailChoreo; // invoke the Temboo client - SendEmailChoreo.begin("temboo"); + // NOTE that the client must be reinvoked, and repopulated with + // appropriate arguments, each time its run() method is called. + SendEmailChoreo.begin(); // set Temboo account credentials - SendEmailChoreo.addParameter("-a"); - SendEmailChoreo.addParameter(TEMBOO_ACCOUNT); - SendEmailChoreo.addParameter("-u"); - SendEmailChoreo.addParameter(TEMBOO_APP_KEY_NAME); - SendEmailChoreo.addParameter("-p"); - SendEmailChoreo.addParameter(TEMBOO_APP_KEY); + SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT); + SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); + SendEmailChoreo.setAppKey(TEMBOO_APP_KEY); // identify the Temboo Library choreo to run (Google > Gmail > SendEmail) - SendEmailChoreo.addParameter("-c"); - SendEmailChoreo.addParameter("/Library/Google/Gmail/SendEmail"); + SendEmailChoreo.setChoreo("/Library/Google/Gmail/SendEmail"); + // set the required choreo inputs // see https://www.temboo.com/library/Library/Google/Gmail/SendEmail/ // for complete details about the inputs for this Choreo - // the first input is a your Gmail user name. - SendEmailChoreo.addParameter("-i"); - SendEmailChoreo.addParameter("Username:" + GMAIL_USER_NAME); - + // the first input is your Gmail email address. + SendEmailChoreo.addInput("Username", GMAIL_USER_NAME); // next is your Gmail password. - SendEmailChoreo.addParameter("-i"); - SendEmailChoreo.addParameter("Password:" + GMAIL_PASSWORD); - + SendEmailChoreo.addInput("Password", GMAIL_PASSWORD); // who to send the email to - SendEmailChoreo.addParameter("-i"); - SendEmailChoreo.addParameter("ToAddress:" + TO_EMAIL_ADDRESS); - + SendEmailChoreo.addInput("ToAddress", TO_EMAIL_ADDRESS); // then a subject line - SendEmailChoreo.addParameter("-i"); - SendEmailChoreo.addParameter("Subject:ALERT: Greenhouse Temperature"); - - // next comes the message body, the main content of the email - SendEmailChoreo.addParameter("-i"); - SendEmailChoreo.addParameter("MessageBody:Hey! The greenhouse is too cold!"); + SendEmailChoreo.addInput("Subject", "ALERT: Greenhouse Temperature"); + + // next comes the message body, the main content of the email + SendEmailChoreo.addInput("MessageBody", "Hey! The greenhouse is too cold!"); - // tell the Process to run and wait for the results. The + // tell the Choreo to run and wait for the results. The // return code (returnCode) will tell us whether the Temboo client // was able to send our request to the Temboo servers unsigned int returnCode = SendEmailChoreo.run(); diff --git a/libraries/Bridge/examples/Temboo/SendAnEmail/TembooAccount.h b/libraries/Bridge/examples/Temboo/SendAnEmail/TembooAccount.h index 8d7dcfb..c58b447 100644 --- a/libraries/Bridge/examples/Temboo/SendAnEmail/TembooAccount.h +++ b/libraries/Bridge/examples/Temboo/SendAnEmail/TembooAccount.h @@ -2,4 +2,3 @@ #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - -- cgit v1.2.3-18-g5258