mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-17 22:23:10 +03:00
updated temboo examples
This commit is contained in:
@ -18,10 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Bridge.h>
|
#include <Bridge.h>
|
||||||
#include <Console.h>
|
#include <Temboo.h>
|
||||||
#include <FileIO.h>
|
|
||||||
#include <HttpClient.h>
|
|
||||||
#include <Process.h>
|
|
||||||
#include "TembooAccount.h" // contains Temboo account information
|
#include "TembooAccount.h" // contains Temboo account information
|
||||||
// as described in the footer comment below
|
// as described in the footer comment below
|
||||||
|
|
||||||
@ -29,9 +26,10 @@
|
|||||||
// the address for which a weather forecast will be retrieved
|
// the address for which a weather forecast will be retrieved
|
||||||
String ADDRESS_FOR_FORECAST = "104 Franklin St., New York NY 10013";
|
String ADDRESS_FOR_FORECAST = "104 Franklin St., New York NY 10013";
|
||||||
|
|
||||||
int numRuns = 0; // execution count, so that this doesn't run forever
|
int numRuns = 1; // execution count, so that this doesn't run forever
|
||||||
int maxRuns = 10; // max number of times the Yahoo WeatherByAddress Choreo should be run
|
int maxRuns = 10; // max number of times the Yahoo WeatherByAddress Choreo should be run
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
@ -39,38 +37,43 @@ void setup() {
|
|||||||
delay(4000);
|
delay(4000);
|
||||||
while(!Serial);
|
while(!Serial);
|
||||||
Bridge.begin();
|
Bridge.begin();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
// while we haven't reached the max number of runs...
|
// while we haven't reached the max number of runs...
|
||||||
if (numRuns < maxRuns) {
|
if (numRuns <= maxRuns) {
|
||||||
|
|
||||||
// print status
|
// print status
|
||||||
Serial.println("Running GetWeatherByAddress - Run #" + String(numRuns++) + "...");
|
Serial.println("Running GetWeatherByAddress - Run #" + String(numRuns++) + "...");
|
||||||
|
|
||||||
// we need a Process object to send a Choreo request to Temboo
|
// create a TembooChoreo object to send a Choreo request to Temboo
|
||||||
Process GetWeatherByAddressChoreo;
|
TembooChoreo GetWeatherByAddressChoreo;
|
||||||
|
|
||||||
// invoke the Temboo client
|
// invoke the Temboo client
|
||||||
GetWeatherByAddressChoreo.begin("temboo");
|
GetWeatherByAddressChoreo.begin();
|
||||||
|
|
||||||
// set Temboo account credentials
|
// add your temboo account info
|
||||||
GetWeatherByAddressChoreo.addParameter("-a");
|
GetWeatherByAddressChoreo.setAccountName(TEMBOO_ACCOUNT);
|
||||||
GetWeatherByAddressChoreo.addParameter(TEMBOO_ACCOUNT);
|
GetWeatherByAddressChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
|
||||||
GetWeatherByAddressChoreo.addParameter("-u");
|
GetWeatherByAddressChoreo.setAppKey(TEMBOO_APP_KEY);
|
||||||
GetWeatherByAddressChoreo.addParameter(TEMBOO_APP_KEY_NAME);
|
|
||||||
GetWeatherByAddressChoreo.addParameter("-p");
|
|
||||||
GetWeatherByAddressChoreo.addParameter(TEMBOO_APP_KEY);
|
|
||||||
|
|
||||||
// identify the Temboo Library choreo to run (Yahoo > Weather > GetWeatherByAddress)
|
// set the name of the choreo we want to run
|
||||||
GetWeatherByAddressChoreo.addParameter("-c");
|
GetWeatherByAddressChoreo.setChoreo("/Library/Yahoo/Weather/GetWeatherByAddress");
|
||||||
GetWeatherByAddressChoreo.addParameter("/Library/Yahoo/Weather/GetWeatherByAddress");
|
|
||||||
|
|
||||||
// set choreo inputs; in this case, the address for which to retrieve weather data
|
// set choreo inputs; in this case, the address for which to retrieve weather data
|
||||||
// the Temboo client provides standardized calls to 100+ cloud APIs
|
// the Temboo client provides standardized calls to 100+ cloud APIs
|
||||||
GetWeatherByAddressChoreo.addParameter("-i");
|
GetWeatherByAddressChoreo.addInput("Address", ADDRESS_FOR_FORECAST);
|
||||||
GetWeatherByAddressChoreo.addParameter("Address:" + ADDRESS_FOR_FORECAST);
|
|
||||||
|
// add an output filter to extract the name of the city.
|
||||||
|
GetWeatherByAddressChoreo.addOutputFilter("city", "/rss/channel/yweather:location/@city", "Response");
|
||||||
|
|
||||||
|
// add an output filter to extract the current temperature
|
||||||
|
GetWeatherByAddressChoreo.addOutputFilter("temperature", "/rss/channel/item/yweather:condition/@temp", "Response");
|
||||||
|
|
||||||
|
// add an output filter to extract the date and time of the last report.
|
||||||
|
GetWeatherByAddressChoreo.addOutputFilter("date", "/rss/channel/item/yweather:condition/@date", "Response");
|
||||||
|
|
||||||
// run the choreo
|
// run the choreo
|
||||||
GetWeatherByAddressChoreo.run();
|
GetWeatherByAddressChoreo.run();
|
||||||
@ -78,9 +81,6 @@ void loop()
|
|||||||
// when the choreo results are available, print them to the serial monitor
|
// when the choreo results are available, print them to the serial monitor
|
||||||
while(GetWeatherByAddressChoreo.available()) {
|
while(GetWeatherByAddressChoreo.available()) {
|
||||||
|
|
||||||
// note that in this example, we just print the raw XML response from Yahoo
|
|
||||||
// see the examples on using Temboo SDK output filters at http://www.temboo.com/arduino
|
|
||||||
// for information on how to filter this data
|
|
||||||
char c = GetWeatherByAddressChoreo.read();
|
char c = GetWeatherByAddressChoreo.read();
|
||||||
Serial.print(c);
|
Serial.print(c);
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Bridge.h>
|
#include <Bridge.h>
|
||||||
#include <Console.h>
|
#include <Temboo.h>
|
||||||
#include <FileIO.h>
|
|
||||||
#include <HttpClient.h>
|
|
||||||
#include <Process.h>
|
|
||||||
#include "TembooAccount.h" // contains Temboo account information
|
#include "TembooAccount.h" // contains Temboo account information
|
||||||
// as described in the footer comment below
|
// as described in the footer comment below
|
||||||
|
|
||||||
@ -40,60 +37,48 @@ const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret";
|
|||||||
const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key";
|
const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key";
|
||||||
const String TWITTER_CONSUMER_SECRET = "your-twitter-consumer-secret";
|
const String TWITTER_CONSUMER_SECRET = "your-twitter-consumer-secret";
|
||||||
|
|
||||||
int numRuns = 1; // execution count, so this sketch doesn't run forever
|
int numRuns = 1; // execution count, so this doesn't run forever
|
||||||
int maxRuns = 10; // the max number of times the Twitter HomeTimeline Choreo should run
|
int maxRuns = 10; // the max number of times the Twitter HomeTimeline Choreo should run
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
// for debugging, wait until a serial console is connected
|
// For debugging, wait until a serial console is connected.
|
||||||
delay(4000);
|
delay(4000);
|
||||||
while(!Serial);
|
while(!Serial);
|
||||||
Bridge.begin();
|
Bridge.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
// while we haven't reached the max number of runs...
|
// while we haven't reached the max number of runs...
|
||||||
if (numRuns <= maxRuns) {
|
if (numRuns <= maxRuns) {
|
||||||
|
Serial.println("Running ReadATweet - Run #" + String(numRuns++));
|
||||||
|
|
||||||
// print status
|
TembooChoreo HomeTimelineChoreo;
|
||||||
Serial.println("Running ReadATweet - Run #" + String(numRuns++) + "...");
|
|
||||||
|
|
||||||
// define the Process that will be used to call the "temboo" client
|
// invoke the Temboo client.
|
||||||
Process HomeTimelineChoreo;
|
// NOTE that the client must be reinvoked, and repopulated with
|
||||||
|
// appropriate arguments, each time its run() method is called.
|
||||||
// invoke the Temboo client
|
HomeTimelineChoreo.begin();
|
||||||
HomeTimelineChoreo.begin("temboo");
|
|
||||||
|
|
||||||
// set Temboo account credentials
|
// set Temboo account credentials
|
||||||
HomeTimelineChoreo.addParameter("-a");
|
HomeTimelineChoreo.setAccountName(TEMBOO_ACCOUNT);
|
||||||
HomeTimelineChoreo.addParameter(TEMBOO_ACCOUNT);
|
HomeTimelineChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
|
||||||
HomeTimelineChoreo.addParameter("-u");
|
HomeTimelineChoreo.setAppKey(TEMBOO_APP_KEY);
|
||||||
HomeTimelineChoreo.addParameter(TEMBOO_APP_KEY_NAME);
|
|
||||||
HomeTimelineChoreo.addParameter("-p");
|
|
||||||
HomeTimelineChoreo.addParameter(TEMBOO_APP_KEY);
|
|
||||||
|
|
||||||
// tell the Temboo client which Choreo to run (Twitter > Timelines > HomeTimeline)
|
// tell the Temboo client which Choreo to run (Twitter > Timelines > HomeTimeline)
|
||||||
HomeTimelineChoreo.addParameter("-c");
|
HomeTimelineChoreo.setChoreo("/Library/Twitter/Timelines/HomeTimeline");
|
||||||
HomeTimelineChoreo.addParameter("/Library/Twitter/Timelines/HomeTimeline");
|
|
||||||
|
|
||||||
// set the required choreo inputs
|
// set the required choreo inputs
|
||||||
// see https://www.temboo.com/library/Library/Twitter/Timelines/HomeTimeline/
|
// see https://www.temboo.com/library/Library/Twitter/Timelines/HomeTimeline/
|
||||||
// for complete details about the inputs for this Choreo
|
// for complete details about the inputs for this Choreo
|
||||||
|
|
||||||
HomeTimelineChoreo.addParameter("-i");
|
HomeTimelineChoreo.addInput("Count", "1"); // the max number of Tweets to return from each request
|
||||||
HomeTimelineChoreo.addParameter("Count:1"); // the max number of Tweets to return from each request
|
HomeTimelineChoreo.addInput("AccessToken", TWITTER_ACCESS_TOKEN);
|
||||||
|
HomeTimelineChoreo.addInput("AccessTokenSecret", TWITTER_ACCESS_TOKEN_SECRET);
|
||||||
// add the Twitter account information
|
HomeTimelineChoreo.addInput("ConsumerKey", TWITTER_CONSUMER_KEY);
|
||||||
HomeTimelineChoreo.addParameter("-i");
|
HomeTimelineChoreo.addInput("ConsumerSecret", TWITTER_CONSUMER_SECRET);
|
||||||
HomeTimelineChoreo.addParameter("AccessToken:" + TWITTER_ACCESS_TOKEN);
|
|
||||||
HomeTimelineChoreo.addParameter("-i");
|
|
||||||
HomeTimelineChoreo.addParameter("AccessTokenSecret:" + TWITTER_ACCESS_TOKEN_SECRET);
|
|
||||||
HomeTimelineChoreo.addParameter("-i");
|
|
||||||
HomeTimelineChoreo.addParameter("ConsumerSecret:" + TWITTER_CONSUMER_SECRET);
|
|
||||||
HomeTimelineChoreo.addParameter("-i");
|
|
||||||
HomeTimelineChoreo.addParameter("ConsumerKey:" + TWITTER_CONSUMER_KEY);
|
|
||||||
|
|
||||||
// next, we'll define two output filters that let us specify the
|
// next, we'll define two output filters that let us specify the
|
||||||
// elements of the response from Twitter that we want to receive.
|
// elements of the response from Twitter that we want to receive.
|
||||||
@ -101,12 +86,10 @@ void loop()
|
|||||||
// for more on using output filters
|
// for more on using output filters
|
||||||
|
|
||||||
// we want the text of the tweet
|
// we want the text of the tweet
|
||||||
HomeTimelineChoreo.addParameter("-o");
|
HomeTimelineChoreo.addOutputFilter("tweet", "/[1]/text", "Response");
|
||||||
HomeTimelineChoreo.addParameter("tweet:/[1]/text:Response");
|
|
||||||
|
|
||||||
// and the name of the author
|
// and the name of the author
|
||||||
HomeTimelineChoreo.addParameter("-o");
|
HomeTimelineChoreo.addOutputFilter("author", "/[1]/user/screen_name", "Response");
|
||||||
HomeTimelineChoreo.addParameter("author:/[1]/user/screen_name:Response");
|
|
||||||
|
|
||||||
|
|
||||||
// tell the Process to run and wait for the results. The
|
// tell the Process to run and wait for the results. The
|
||||||
@ -160,30 +143,9 @@ void loop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
HomeTimelineChoreo.close();
|
HomeTimelineChoreo.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("Waiting...");
|
Serial.println("Waiting...");
|
||||||
Serial.println("");
|
|
||||||
delay(90000); // wait 90 seconds between HomeTimeline calls
|
delay(90000); // wait 90 seconds between HomeTimeline calls
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
IMPORTANT NOTE: TembooAccount.h:
|
|
||||||
|
|
||||||
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
|
||||||
You'll need to edit the placeholder version of TembooAccount.h included with this example sketch,
|
|
||||||
by inserting your own Temboo account name and app key information. The contents of the file should
|
|
||||||
look like:
|
|
||||||
|
|
||||||
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
|
|
||||||
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
|
|
||||||
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
|
|
||||||
|
|
||||||
You can find your Temboo App Key information on the Temboo website,
|
|
||||||
under My Account > Application Keys
|
|
||||||
|
|
||||||
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
|
|
||||||
|
|
||||||
Keeping your account information in a separate file means you can save it once,
|
|
||||||
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
|
|
||||||
*/
|
|
||||||
|
@ -25,10 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Bridge.h>
|
#include <Bridge.h>
|
||||||
#include <Console.h>
|
#include <Temboo.h>
|
||||||
#include <FileIO.h>
|
|
||||||
#include <HttpClient.h>
|
|
||||||
#include <Process.h>
|
|
||||||
#include "TembooAccount.h" // contains Temboo account information
|
#include "TembooAccount.h" // contains Temboo account information
|
||||||
// as described in the footer comment below
|
// as described in the footer comment below
|
||||||
|
|
||||||
@ -43,7 +40,7 @@ const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key";
|
|||||||
const String TWITTER_CONSUMER_SECRET = "your-twitter-consumer-secret";
|
const String TWITTER_CONSUMER_SECRET = "your-twitter-consumer-secret";
|
||||||
|
|
||||||
int numRuns = 1; // execution count, so this sketch doesn't run forever
|
int numRuns = 1; // execution count, so this sketch doesn't run forever
|
||||||
int maxRuns = 10; // the max number of times the Twitter HomeTimeline Choreo should run
|
int maxRuns = 3; // the max number of times the Twitter Update Choreo should run
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
@ -62,42 +59,37 @@ void loop()
|
|||||||
|
|
||||||
Serial.println("Running SendATweet - Run #" + String(numRuns++) + "...");
|
Serial.println("Running SendATweet - Run #" + String(numRuns++) + "...");
|
||||||
|
|
||||||
// we need a Process object to send a Choreo request to Temboo
|
// define the text of the tweet we want to send
|
||||||
Process StatusesUpdateChoreo;
|
String tweetText("My Arduino Yun has been running for " + String(millis()) + " milliseconds.");
|
||||||
|
|
||||||
|
|
||||||
|
TembooChoreo StatusesUpdateChoreo;
|
||||||
|
|
||||||
// invoke the Temboo client
|
// invoke the Temboo client
|
||||||
StatusesUpdateChoreo.begin("temboo");
|
// NOTE that the client must be reinvoked, and repopulated with
|
||||||
|
// appropriate arguments, each time its run() method is called.
|
||||||
|
StatusesUpdateChoreo.begin();
|
||||||
|
|
||||||
// set Temboo account credentials
|
// set Temboo account credentials
|
||||||
StatusesUpdateChoreo.addParameter("-a");
|
StatusesUpdateChoreo.setAccountName(TEMBOO_ACCOUNT);
|
||||||
StatusesUpdateChoreo.addParameter(TEMBOO_ACCOUNT);
|
StatusesUpdateChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
|
||||||
StatusesUpdateChoreo.addParameter("-u");
|
StatusesUpdateChoreo.setAppKey(TEMBOO_APP_KEY);
|
||||||
StatusesUpdateChoreo.addParameter(TEMBOO_APP_KEY_NAME);
|
|
||||||
StatusesUpdateChoreo.addParameter("-p");
|
|
||||||
StatusesUpdateChoreo.addParameter(TEMBOO_APP_KEY);
|
|
||||||
|
|
||||||
// identify the Temboo Library choreo to run (Twitter > Tweets > StatusesUpdate)
|
// identify the Temboo Library choreo to run (Twitter > Tweets > StatusesUpdate)
|
||||||
StatusesUpdateChoreo.addParameter("-c");
|
StatusesUpdateChoreo.setChoreo("/Library/Twitter/Tweets/StatusesUpdate");
|
||||||
StatusesUpdateChoreo.addParameter("/Library/Twitter/Tweets/StatusesUpdate");
|
|
||||||
|
|
||||||
// set the required choreo inputs
|
// set the required choreo inputs
|
||||||
// see https://www.temboo.com/library/Library/Twitter/Tweets/StatusesUpdate/
|
// see https://www.temboo.com/library/Library/Twitter/Tweets/StatusesUpdate/
|
||||||
// for complete details about the inputs for this Choreo
|
// for complete details about the inputs for this Choreo
|
||||||
|
|
||||||
// add the Twitter account information
|
// add the Twitter account information
|
||||||
StatusesUpdateChoreo.addParameter("-i");
|
StatusesUpdateChoreo.addInput("AccessToken", TWITTER_ACCESS_TOKEN);
|
||||||
StatusesUpdateChoreo.addParameter("AccessToken:" + TWITTER_ACCESS_TOKEN);
|
StatusesUpdateChoreo.addInput("AccessTokenSecret", TWITTER_ACCESS_TOKEN_SECRET);
|
||||||
StatusesUpdateChoreo.addParameter("-i");
|
StatusesUpdateChoreo.addInput("ConsumerKey", TWITTER_CONSUMER_KEY);
|
||||||
StatusesUpdateChoreo.addParameter("AccessTokenSecret:" + TWITTER_ACCESS_TOKEN_SECRET);
|
StatusesUpdateChoreo.addInput("ConsumerSecret", TWITTER_CONSUMER_SECRET);
|
||||||
StatusesUpdateChoreo.addParameter("-i");
|
|
||||||
StatusesUpdateChoreo.addParameter("ConsumerSecret:" + TWITTER_CONSUMER_SECRET);
|
|
||||||
StatusesUpdateChoreo.addParameter("-i");
|
|
||||||
StatusesUpdateChoreo.addParameter("ConsumerKey:" + TWITTER_CONSUMER_KEY);
|
|
||||||
|
|
||||||
String tweet("My Arduino Yun has been running for " + String(millis()) + " milliseconds.");
|
// and the tweet we want to send
|
||||||
|
StatusesUpdateChoreo.addInput("StatusUpdate", tweetText);
|
||||||
StatusesUpdateChoreo.addParameter("-i");
|
|
||||||
StatusesUpdateChoreo.addParameter("StatusUpdate:" + tweet);
|
|
||||||
|
|
||||||
// tell the Process to run and wait for the results. The
|
// tell the Process to run and wait for the results. The
|
||||||
// return code (returnCode) will tell us whether the Temboo client
|
// return code (returnCode) will tell us whether the Temboo client
|
||||||
|
@ -22,10 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Bridge.h>
|
#include <Bridge.h>
|
||||||
#include <Console.h>
|
#include <Temboo.h>
|
||||||
#include <FileIO.h>
|
|
||||||
#include <HttpClient.h>
|
|
||||||
#include <Process.h>
|
|
||||||
#include "TembooAccount.h" // contains Temboo account information
|
#include "TembooAccount.h" // contains Temboo account information
|
||||||
// as described in the footer comment below
|
// as described in the footer comment below
|
||||||
|
|
||||||
@ -34,7 +31,7 @@
|
|||||||
// Note that for additional security and reusability, you could
|
// Note that for additional security and reusability, you could
|
||||||
// use #define statements to specify these values in a .h file.
|
// 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";
|
const String GMAIL_USER_NAME = "xxxxxxxxxx";
|
||||||
|
|
||||||
// your Gmail password
|
// your Gmail password
|
||||||
@ -63,49 +60,39 @@ void loop()
|
|||||||
|
|
||||||
Serial.println("Running SendAnEmail...");
|
Serial.println("Running SendAnEmail...");
|
||||||
|
|
||||||
// we need a Process object to send a Choreo request to Temboo
|
TembooChoreo SendEmailChoreo;
|
||||||
Process SendEmailChoreo;
|
|
||||||
|
|
||||||
// invoke the Temboo client
|
// 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
|
// set Temboo account credentials
|
||||||
SendEmailChoreo.addParameter("-a");
|
SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT);
|
||||||
SendEmailChoreo.addParameter(TEMBOO_ACCOUNT);
|
SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
|
||||||
SendEmailChoreo.addParameter("-u");
|
SendEmailChoreo.setAppKey(TEMBOO_APP_KEY);
|
||||||
SendEmailChoreo.addParameter(TEMBOO_APP_KEY_NAME);
|
|
||||||
SendEmailChoreo.addParameter("-p");
|
|
||||||
SendEmailChoreo.addParameter(TEMBOO_APP_KEY);
|
|
||||||
|
|
||||||
// identify the Temboo Library choreo to run (Google > Gmail > SendEmail)
|
// identify the Temboo Library choreo to run (Google > Gmail > SendEmail)
|
||||||
SendEmailChoreo.addParameter("-c");
|
SendEmailChoreo.setChoreo("/Library/Google/Gmail/SendEmail");
|
||||||
SendEmailChoreo.addParameter("/Library/Google/Gmail/SendEmail");
|
|
||||||
|
|
||||||
// set the required choreo inputs
|
// set the required choreo inputs
|
||||||
// see https://www.temboo.com/library/Library/Google/Gmail/SendEmail/
|
// see https://www.temboo.com/library/Library/Google/Gmail/SendEmail/
|
||||||
// for complete details about the inputs for this Choreo
|
// for complete details about the inputs for this Choreo
|
||||||
|
|
||||||
// the first input is a your Gmail user name.
|
// the first input is your Gmail email address.
|
||||||
SendEmailChoreo.addParameter("-i");
|
SendEmailChoreo.addInput("Username", GMAIL_USER_NAME);
|
||||||
SendEmailChoreo.addParameter("Username:" + GMAIL_USER_NAME);
|
|
||||||
|
|
||||||
// next is your Gmail password.
|
// next is your Gmail password.
|
||||||
SendEmailChoreo.addParameter("-i");
|
SendEmailChoreo.addInput("Password", GMAIL_PASSWORD);
|
||||||
SendEmailChoreo.addParameter("Password:" + GMAIL_PASSWORD);
|
|
||||||
|
|
||||||
// who to send the email to
|
// who to send the email to
|
||||||
SendEmailChoreo.addParameter("-i");
|
SendEmailChoreo.addInput("ToAddress", TO_EMAIL_ADDRESS);
|
||||||
SendEmailChoreo.addParameter("ToAddress:" + TO_EMAIL_ADDRESS);
|
|
||||||
|
|
||||||
// then a subject line
|
// then a subject line
|
||||||
SendEmailChoreo.addParameter("-i");
|
SendEmailChoreo.addInput("Subject", "ALERT: Greenhouse Temperature");
|
||||||
SendEmailChoreo.addParameter("Subject:ALERT: Greenhouse Temperature");
|
|
||||||
|
|
||||||
// next comes the message body, the main content of the email
|
// next comes the message body, the main content of the email
|
||||||
SendEmailChoreo.addParameter("-i");
|
SendEmailChoreo.addInput("MessageBody", "Hey! The greenhouse is too cold!");
|
||||||
SendEmailChoreo.addParameter("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
|
// return code (returnCode) will tell us whether the Temboo client
|
||||||
// was able to send our request to the Temboo servers
|
// was able to send our request to the Temboo servers
|
||||||
unsigned int returnCode = SendEmailChoreo.run();
|
unsigned int returnCode = SendEmailChoreo.run();
|
||||||
|
@ -2,4 +2,3 @@
|
|||||||
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
|
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
|
||||||
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
|
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,10 +31,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Bridge.h>
|
#include <Bridge.h>
|
||||||
#include <Console.h>
|
#include <Temboo.h>
|
||||||
#include <FileIO.h>
|
|
||||||
#include <HttpClient.h>
|
|
||||||
#include <Process.h>
|
|
||||||
#include "TembooAccount.h" // contains Temboo account information
|
#include "TembooAccount.h" // contains Temboo account information
|
||||||
// as described in the footer comment below
|
// as described in the footer comment below
|
||||||
|
|
||||||
@ -77,46 +74,39 @@ void loop()
|
|||||||
Serial.println("Running SendAnSMS...");
|
Serial.println("Running SendAnSMS...");
|
||||||
|
|
||||||
// we need a Process object to send a Choreo request to Temboo
|
// we need a Process object to send a Choreo request to Temboo
|
||||||
Process SendSMSChoreo;
|
TembooChoreo SendSMSChoreo;
|
||||||
|
|
||||||
// invoke the Temboo client
|
// invoke the Temboo client
|
||||||
SendSMSChoreo.begin("temboo");
|
// NOTE that the client must be reinvoked and repopulated with
|
||||||
|
// appropriate arguments each time its run() method is called.
|
||||||
|
SendSMSChoreo.begin();
|
||||||
|
|
||||||
// set Temboo account credentials
|
// set Temboo account credentials
|
||||||
SendSMSChoreo.addParameter("-a");
|
SendSMSChoreo.setAccountName(TEMBOO_ACCOUNT);
|
||||||
SendSMSChoreo.addParameter(TEMBOO_ACCOUNT);
|
SendSMSChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
|
||||||
SendSMSChoreo.addParameter("-u");
|
SendSMSChoreo.setAppKey(TEMBOO_APP_KEY);
|
||||||
SendSMSChoreo.addParameter(TEMBOO_APP_KEY_NAME);
|
|
||||||
SendSMSChoreo.addParameter("-p");
|
|
||||||
SendSMSChoreo.addParameter(TEMBOO_APP_KEY);
|
|
||||||
|
|
||||||
// identify the Temboo Library choreo to run (Twilio > SMSMessages > SendSMS)
|
// identify the Temboo Library choreo to run (Twilio > SMSMessages > SendSMS)
|
||||||
SendSMSChoreo.addParameter("-c");
|
SendSMSChoreo.setChoreo("/Library/Twilio/SMSMessages/SendSMS");
|
||||||
SendSMSChoreo.addParameter("/Library/Twilio/SMSMessages/SendSMS");
|
|
||||||
|
|
||||||
// set the required choreo inputs
|
// set the required choreo inputs
|
||||||
// see https://www.temboo.com/library/Library/Twilio/SMSMessages/SendSMS/
|
// see https://www.temboo.com/library/Library/Twilio/SMSMessages/SendSMS/
|
||||||
// for complete details about the inputs for this Choreo
|
// for complete details about the inputs for this Choreo
|
||||||
|
|
||||||
// the first input is a your AccountSID
|
// the first input is a your AccountSID
|
||||||
SendSMSChoreo.addParameter("-i");
|
SendSMSChoreo.addInput("AccountSID", TWILIO_ACCOUNT_SID);
|
||||||
SendSMSChoreo.addParameter("AccountSID:" + TWILIO_ACCOUNT_SID);
|
|
||||||
|
|
||||||
// next is your Auth Token
|
// next is your Auth Token
|
||||||
SendSMSChoreo.addParameter("-i");
|
SendSMSChoreo.addInput("AuthToken", TWILIO_AUTH_TOKEN);
|
||||||
SendSMSChoreo.addParameter("AuthToken:" + TWILIO_AUTH_TOKEN);
|
|
||||||
|
|
||||||
// next is your Twilio phone number
|
// next is your Twilio phone number
|
||||||
SendSMSChoreo.addParameter("-i");
|
SendSMSChoreo.addInput("From", TWILIO_NUMBER);
|
||||||
SendSMSChoreo.addParameter("From:" + TWILIO_NUMBER);
|
|
||||||
|
|
||||||
// next, what number to send the SMS to
|
// next, what number to send the SMS to
|
||||||
SendSMSChoreo.addParameter("-i");
|
SendSMSChoreo.addInput("To", RECIPIENT_NUMBER);
|
||||||
SendSMSChoreo.addParameter("To:" + RECIPIENT_NUMBER);
|
|
||||||
|
|
||||||
// finally, the text of the message to send
|
// finally, the text of the message to send
|
||||||
SendSMSChoreo.addParameter("-i");
|
SendSMSChoreo.addInput("Body", "Hey, there! This is a message from your Arduino Yun!");
|
||||||
SendSMSChoreo.addParameter("Body:Hey, there! This is a message from your Arduino Yun!");
|
|
||||||
|
|
||||||
// tell the Process to run and wait for the results. The
|
// tell the Process to run and wait for the results. The
|
||||||
// return code (returnCode) will tell us whether the Temboo client
|
// return code (returnCode) will tell us whether the Temboo client
|
||||||
|
@ -37,10 +37,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Bridge.h>
|
#include <Bridge.h>
|
||||||
#include <Console.h>
|
#include <Temboo.h>
|
||||||
#include <FileIO.h>
|
|
||||||
#include <HttpClient.h>
|
|
||||||
#include <Process.h>
|
|
||||||
#include "TembooAccount.h" // contains Temboo account information,
|
#include "TembooAccount.h" // contains Temboo account information,
|
||||||
// as described in the footer comment below
|
// as described in the footer comment below
|
||||||
|
|
||||||
@ -97,39 +94,34 @@ void loop()
|
|||||||
Serial.println("Appending value to spreadsheet...");
|
Serial.println("Appending value to spreadsheet...");
|
||||||
|
|
||||||
// we need a Process object to send a Choreo request to Temboo
|
// we need a Process object to send a Choreo request to Temboo
|
||||||
Process AppendRowChoreo;
|
TembooChoreo AppendRowChoreo;
|
||||||
|
|
||||||
// invoke the Temboo client
|
// invoke the Temboo client
|
||||||
AppendRowChoreo.begin("temboo");
|
// NOTE that the client must be reinvoked and repopulated with
|
||||||
|
// appropriate arguments each time its run() method is called.
|
||||||
|
AppendRowChoreo.begin();
|
||||||
|
|
||||||
// set Temboo account credentials
|
// set Temboo account credentials
|
||||||
AppendRowChoreo.addParameter("-a");
|
AppendRowChoreo.setAccountName(TEMBOO_ACCOUNT);
|
||||||
AppendRowChoreo.addParameter(TEMBOO_ACCOUNT);
|
AppendRowChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
|
||||||
AppendRowChoreo.addParameter("-u");
|
AppendRowChoreo.setAppKey(TEMBOO_APP_KEY);
|
||||||
AppendRowChoreo.addParameter(TEMBOO_APP_KEY_NAME);
|
|
||||||
AppendRowChoreo.addParameter("-p");
|
|
||||||
AppendRowChoreo.addParameter(TEMBOO_APP_KEY);
|
|
||||||
|
|
||||||
// identify the Temboo Library choreo to run (Google > Spreadsheets > AppendRow)
|
// identify the Temboo Library choreo to run (Google > Spreadsheets > AppendRow)
|
||||||
AppendRowChoreo.addParameter("-c");
|
AppendRowChoreo.setChoreo("/Library/Google/Spreadsheets/AppendRow");
|
||||||
AppendRowChoreo.addParameter("/Library/Google/Spreadsheets/AppendRow");
|
|
||||||
|
|
||||||
// set the required Choreo inputs
|
// set the required Choreo inputs
|
||||||
// see https://www.temboo.com/library/Library/Google/Spreadsheets/AppendRow/
|
// see https://www.temboo.com/library/Library/Google/Spreadsheets/AppendRow/
|
||||||
// for complete details about the inputs for this Choreo
|
// for complete details about the inputs for this Choreo
|
||||||
|
|
||||||
// your Google username (usually your email address)
|
// your Google username (usually your email address)
|
||||||
AppendRowChoreo.addParameter("-i");
|
AppendRowChoreo.addInput("Username", GOOGLE_USERNAME);
|
||||||
AppendRowChoreo.addParameter("Username:" + GOOGLE_USERNAME);
|
|
||||||
|
|
||||||
// your Google account password
|
// your Google account password
|
||||||
AppendRowChoreo.addParameter("-i");
|
AppendRowChoreo.addInput("Password", GOOGLE_PASSWORD);
|
||||||
AppendRowChoreo.addParameter("Password:" + GOOGLE_PASSWORD);
|
|
||||||
|
|
||||||
// the title of the spreadsheet you want to append to
|
// the title of the spreadsheet you want to append to
|
||||||
// NOTE: substitute your own value, retaining the "SpreadsheetTitle:" prefix.
|
// NOTE: substitute your own value, retaining the "SpreadsheetTitle:" prefix.
|
||||||
AppendRowChoreo.addParameter("-i");
|
AppendRowChoreo.addInput("SpreadsheetTitle", SPREADSHEET_TITLE);
|
||||||
AppendRowChoreo.addParameter("SpreadsheetTitle:" + SPREADSHEET_TITLE);
|
|
||||||
|
|
||||||
// convert the time and sensor values to a comma separated string
|
// convert the time and sensor values to a comma separated string
|
||||||
String rowData(now);
|
String rowData(now);
|
||||||
@ -137,8 +129,7 @@ void loop()
|
|||||||
rowData += sensorValue;
|
rowData += sensorValue;
|
||||||
|
|
||||||
// add the RowData input item
|
// add the RowData input item
|
||||||
AppendRowChoreo.addParameter("-i");
|
AppendRowChoreo.addInput("RowData", rowData);
|
||||||
AppendRowChoreo.addParameter("RowData:" + rowData);
|
|
||||||
|
|
||||||
// run the Choreo and wait for the results
|
// run the Choreo and wait for the results
|
||||||
// The return code (returnCode) will indicate success or failure
|
// The return code (returnCode) will indicate success or failure
|
||||||
|
@ -20,10 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Bridge.h>
|
#include <Bridge.h>
|
||||||
#include <Console.h>
|
#include <Temboo.h>
|
||||||
#include <FileIO.h>
|
|
||||||
#include <HttpClient.h>
|
|
||||||
#include <Process.h>
|
|
||||||
#include "TembooAccount.h" // contains Temboo account information
|
#include "TembooAccount.h" // contains Temboo account information
|
||||||
// as described in the footer comment below
|
// as described in the footer comment below
|
||||||
|
|
||||||
@ -51,35 +48,30 @@ void loop()
|
|||||||
Serial.println("Running ToxicFacilitiesSearch - Run #" + String(numRuns++) + "...");
|
Serial.println("Running ToxicFacilitiesSearch - Run #" + String(numRuns++) + "...");
|
||||||
|
|
||||||
// we need a Process object to send a Choreo request to Temboo
|
// we need a Process object to send a Choreo request to Temboo
|
||||||
Process FacilitiesSearchByZipChoreo;
|
TembooChoreo FacilitiesSearchByZipChoreo;
|
||||||
|
|
||||||
// invoke the Temboo client
|
// invoke the Temboo client
|
||||||
FacilitiesSearchByZipChoreo.begin("temboo");
|
// NOTE that the client must be reinvoked and repopulated with
|
||||||
|
// appropriate arguments each time its run() method is called.
|
||||||
|
FacilitiesSearchByZipChoreo.begin();
|
||||||
|
|
||||||
// set Temboo account credentials
|
// set Temboo account credentials
|
||||||
FacilitiesSearchByZipChoreo.addParameter("-a");
|
FacilitiesSearchByZipChoreo.setAccountName(TEMBOO_ACCOUNT);
|
||||||
FacilitiesSearchByZipChoreo.addParameter(TEMBOO_ACCOUNT);
|
FacilitiesSearchByZipChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
|
||||||
FacilitiesSearchByZipChoreo.addParameter("-u");
|
FacilitiesSearchByZipChoreo.setAppKey(TEMBOO_APP_KEY);
|
||||||
FacilitiesSearchByZipChoreo.addParameter(TEMBOO_APP_KEY_NAME);
|
|
||||||
FacilitiesSearchByZipChoreo.addParameter("-p");
|
|
||||||
FacilitiesSearchByZipChoreo.addParameter(TEMBOO_APP_KEY);
|
|
||||||
|
|
||||||
// identify the Temboo Library choreo to run (EnviroFacts > Toxins > FacilitiesSearchByZip)
|
// identify the Temboo Library choreo to run (EnviroFacts > Toxins > FacilitiesSearchByZip)
|
||||||
FacilitiesSearchByZipChoreo.addParameter("-c");
|
FacilitiesSearchByZipChoreo.setChoreo("/Library/EnviroFacts/Toxins/FacilitiesSearchByZip");
|
||||||
FacilitiesSearchByZipChoreo.addParameter("/Library/EnviroFacts/Toxins/FacilitiesSearchByZip");
|
|
||||||
|
|
||||||
// set choreo inputs; in this case, the US zip code for which to retrieve toxin release data
|
// set choreo inputs; in this case, the US zip code for which to retrieve toxin release data
|
||||||
// the Temboo client provides standardized calls to 100+ cloud APIs
|
// the Temboo client provides standardized calls to 100+ cloud APIs
|
||||||
FacilitiesSearchByZipChoreo.addParameter("-i");
|
FacilitiesSearchByZipChoreo.addInput("Zip", US_ZIP_CODE);
|
||||||
FacilitiesSearchByZipChoreo.addParameter("Zip:" + US_ZIP_CODE);
|
|
||||||
|
|
||||||
// specify two output filters, to help simplify the Envirofacts API results.
|
// specify two output filters, to help simplify the Envirofacts API results.
|
||||||
// see the tutorials on using Temboo SDK output filters at http://www.temboo.com/arduino
|
// see the tutorials on using Temboo SDK output filters at http://www.temboo.com/arduino
|
||||||
FacilitiesSearchByZipChoreo.addParameter("-o");
|
FacilitiesSearchByZipChoreo.addOutputFilter("fac", "FACILITY_NAME", "Response");
|
||||||
FacilitiesSearchByZipChoreo.addParameter("fac:FACILITY_NAME:Response");
|
|
||||||
|
|
||||||
FacilitiesSearchByZipChoreo.addParameter("-o");
|
FacilitiesSearchByZipChoreo.addOutputFilter("addr", "STREET_ADDRESS", "Response");
|
||||||
FacilitiesSearchByZipChoreo.addParameter("addr:STREET_ADDRESS:Response");
|
|
||||||
|
|
||||||
// run the choreo
|
// run the choreo
|
||||||
unsigned int returnCode = FacilitiesSearchByZipChoreo.run();
|
unsigned int returnCode = FacilitiesSearchByZipChoreo.run();
|
||||||
|
@ -24,10 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Bridge.h>
|
#include <Bridge.h>
|
||||||
#include <Console.h>
|
#include <Temboo.h>
|
||||||
#include <FileIO.h>
|
|
||||||
#include <HttpClient.h>
|
|
||||||
#include <Process.h>
|
|
||||||
#include "TembooAccount.h" // contains Temboo account information,
|
#include "TembooAccount.h" // contains Temboo account information,
|
||||||
// as described in the footer comment below
|
// as described in the footer comment below
|
||||||
|
|
||||||
@ -40,7 +37,7 @@
|
|||||||
const String FACEBOOK_ACCESS_TOKEN = "xxxxxxxxxx";
|
const String FACEBOOK_ACCESS_TOKEN = "xxxxxxxxxx";
|
||||||
|
|
||||||
|
|
||||||
int numRuns = 0; // execution count, so this sketch doesn't run forever
|
int numRuns = 1; // execution count, so this sketch doesn't run forever
|
||||||
int maxRuns = 10; // the max number of times the Facebook SetStatus Choreo should run
|
int maxRuns = 10; // the max number of times the Facebook SetStatus Choreo should run
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
@ -54,7 +51,7 @@ void setup() {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// while we haven't reached the max number of runs...
|
// while we haven't reached the max number of runs...
|
||||||
if (numRuns < maxRuns) {
|
if (numRuns <= maxRuns) {
|
||||||
|
|
||||||
// print status
|
// print status
|
||||||
Serial.println("Running UpdateFacebookStatus - Run #" + String(numRuns++) + "...");
|
Serial.println("Running UpdateFacebookStatus - Run #" + String(numRuns++) + "...");
|
||||||
@ -64,31 +61,27 @@ void loop() {
|
|||||||
String statusMsg = "My Arduino Yun has been running for " + String(millis()) + " milliseconds!";
|
String statusMsg = "My Arduino Yun has been running for " + String(millis()) + " milliseconds!";
|
||||||
|
|
||||||
// define the Process that will be used to call the "temboo" client
|
// define the Process that will be used to call the "temboo" client
|
||||||
Process SetStatusChoreo;
|
TembooChoreo SetStatusChoreo;
|
||||||
|
|
||||||
// invoke the Temboo client
|
// invoke the Temboo client
|
||||||
SetStatusChoreo.begin("temboo");
|
// NOTE that the client must be reinvoked and repopulated with
|
||||||
|
// appropriate arguments each time its run() method is called.
|
||||||
|
SetStatusChoreo.begin();
|
||||||
|
|
||||||
// set Temboo account credentials
|
// set Temboo account credentials
|
||||||
SetStatusChoreo.addParameter("-a");
|
SetStatusChoreo.setAccountName(TEMBOO_ACCOUNT);
|
||||||
SetStatusChoreo.addParameter(TEMBOO_ACCOUNT);
|
SetStatusChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
|
||||||
SetStatusChoreo.addParameter("-u");
|
SetStatusChoreo.setAppKey(TEMBOO_APP_KEY);
|
||||||
SetStatusChoreo.addParameter(TEMBOO_APP_KEY_NAME);
|
|
||||||
SetStatusChoreo.addParameter("-p");
|
|
||||||
SetStatusChoreo.addParameter(TEMBOO_APP_KEY);
|
|
||||||
|
|
||||||
// tell the Temboo client which Choreo to run (Facebook > Publishing > SetStatus)
|
// tell the Temboo client which Choreo to run (Facebook > Publishing > SetStatus)
|
||||||
SetStatusChoreo.addParameter("-c");
|
SetStatusChoreo.setChoreo("/Library/Facebook/Publishing/SetStatus");
|
||||||
SetStatusChoreo.addParameter("/Library/Facebook/Publishing/SetStatus");
|
|
||||||
|
|
||||||
// set the required choreo inputs
|
// set the required choreo inputs
|
||||||
// see https://www.temboo.com/library/Library/Facebook/Publishing/SetStatus/
|
// see https://www.temboo.com/library/Library/Facebook/Publishing/SetStatus/
|
||||||
// for complete details about the inputs for this Choreo
|
// for complete details about the inputs for this Choreo
|
||||||
|
|
||||||
SetStatusChoreo.addParameter("-i");
|
SetStatusChoreo.addInput("AccessToken", FACEBOOK_ACCESS_TOKEN);
|
||||||
SetStatusChoreo.addParameter("AccessToken:" + FACEBOOK_ACCESS_TOKEN);
|
SetStatusChoreo.addInput("Message", statusMsg);
|
||||||
SetStatusChoreo.addParameter("-i");
|
|
||||||
SetStatusChoreo.addParameter("Message:" + statusMsg);
|
|
||||||
|
|
||||||
|
|
||||||
// tell the Process to run and wait for the results. The
|
// tell the Process to run and wait for the results. The
|
||||||
|
@ -25,10 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Bridge.h>
|
#include <Bridge.h>
|
||||||
#include <Console.h>
|
#include <Temboo.h>
|
||||||
#include <FileIO.h>
|
|
||||||
#include <HttpClient.h>
|
|
||||||
#include <Process.h>
|
|
||||||
#include "TembooAccount.h" // contains Temboo account information
|
#include "TembooAccount.h" // contains Temboo account information
|
||||||
// as described in the footer comment below
|
// as described in the footer comment below
|
||||||
|
|
||||||
@ -76,49 +73,40 @@ void loop()
|
|||||||
Serial.println("Uploading data to Dropbox...");
|
Serial.println("Uploading data to Dropbox...");
|
||||||
|
|
||||||
// we need a Process object to send a Choreo request to Temboo
|
// we need a Process object to send a Choreo request to Temboo
|
||||||
Process UploadFileChoreo;
|
TembooChoreo UploadFileChoreo;
|
||||||
|
|
||||||
// invoke the Temboo client
|
// invoke the Temboo client
|
||||||
UploadFileChoreo.begin("temboo");
|
// NOTE that the client must be reinvoked and repopulated with
|
||||||
|
// appropriate arguments each time its run() method is called.
|
||||||
|
UploadFileChoreo.begin();
|
||||||
|
|
||||||
// set Temboo account credentials
|
// set Temboo account credentials
|
||||||
UploadFileChoreo.addParameter("-a");
|
UploadFileChoreo.setAccountName(TEMBOO_ACCOUNT);
|
||||||
UploadFileChoreo.addParameter(TEMBOO_ACCOUNT);
|
UploadFileChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
|
||||||
UploadFileChoreo.addParameter("-u");
|
UploadFileChoreo.setAppKey(TEMBOO_APP_KEY);
|
||||||
UploadFileChoreo.addParameter(TEMBOO_APP_KEY_NAME);
|
|
||||||
UploadFileChoreo.addParameter("-p");
|
|
||||||
UploadFileChoreo.addParameter(TEMBOO_APP_KEY);
|
|
||||||
|
|
||||||
// identify the Temboo Library choreo to run (Dropbox > FilesAndMetadata > UploadFile)
|
// identify the Temboo Library choreo to run (Dropbox > FilesAndMetadata > UploadFile)
|
||||||
UploadFileChoreo.addParameter("-c");
|
UploadFileChoreo.setChoreo("/Library/Dropbox/FilesAndMetadata/UploadFile");
|
||||||
UploadFileChoreo.addParameter("/Library/Dropbox/FilesAndMetadata/UploadFile");
|
|
||||||
|
|
||||||
// set the required choreo inputs
|
// set the required choreo inputs
|
||||||
// see https://www.temboo.com/library/Library/Dropbox/FilesAndMetadata/UploadFile/
|
// see https://www.temboo.com/library/Library/Dropbox/FilesAndMetadata/UploadFile/
|
||||||
// for complete details about the inputs for this Choreo
|
// for complete details about the inputs for this Choreo
|
||||||
|
|
||||||
// first specify the name of the file to create/update on Dropbox
|
// first specify the name of the file to create/update on Dropbox
|
||||||
UploadFileChoreo.addParameter("-i");
|
UploadFileChoreo.addInput("FileName", "ArduinoTest.txt");
|
||||||
UploadFileChoreo.addParameter("FileName:ArduinoTest.txt");
|
|
||||||
|
|
||||||
// next, the root folder on Dropbox relative to which the file path is specified.
|
// next, the root folder on Dropbox relative to which the file path is specified.
|
||||||
// unless you're using an in-production Dropbox app, this should be left as "sandbox"
|
// unless you're using an in-production Dropbox app, this should be left as "sandbox"
|
||||||
UploadFileChoreo.addParameter("-i");
|
UploadFileChoreo.addInput("Root","sandbox");
|
||||||
UploadFileChoreo.addParameter("Root:sandbox");
|
|
||||||
|
|
||||||
// next, the Base64 encoded file data to upload
|
// next, the Base64 encoded file data to upload
|
||||||
UploadFileChoreo.addParameter("-i");
|
UploadFileChoreo.addInput("FileContents", base64EncodedData);
|
||||||
UploadFileChoreo.addParameter("FileContents:" + base64EncodedData);
|
|
||||||
|
|
||||||
// finally, the Dropbox OAuth credentials defined above
|
// finally, the Dropbox OAuth credentials defined above
|
||||||
UploadFileChoreo.addParameter("-i");
|
UploadFileChoreo.addInput("AppSecret", DROPBOX_APP_SECRET);
|
||||||
UploadFileChoreo.addParameter("AppSecret:" + DROPBOX_APP_SECRET);
|
UploadFileChoreo.addInput("AccessToken", DROPBOX_ACCESS_TOKEN);
|
||||||
UploadFileChoreo.addParameter("-i");
|
UploadFileChoreo.addInput("AccessTokenSecret", DROPBOX_ACCESS_TOKEN_SECRET);
|
||||||
UploadFileChoreo.addParameter("AccessToken:" + DROPBOX_ACCESS_TOKEN);
|
UploadFileChoreo.addInput("AppKey", DROPBOX_APP_KEY);
|
||||||
UploadFileChoreo.addParameter("-i");
|
|
||||||
UploadFileChoreo.addParameter("AccessTokenSecret:" + DROPBOX_ACCESS_TOKEN_SECRET);
|
|
||||||
UploadFileChoreo.addParameter("-i");
|
|
||||||
UploadFileChoreo.addParameter("AppKey:" + DROPBOX_APP_KEY);
|
|
||||||
|
|
||||||
// tell the Process to run and wait for the results. The
|
// tell the Process to run and wait for the results. The
|
||||||
// return code (returnCode) will tell us whether the Temboo client
|
// return code (returnCode) will tell us whether the Temboo client
|
||||||
@ -156,26 +144,21 @@ void loop()
|
|||||||
String base64Encode(String toEncode) {
|
String base64Encode(String toEncode) {
|
||||||
|
|
||||||
// we need a Process object to send a Choreo request to Temboo
|
// we need a Process object to send a Choreo request to Temboo
|
||||||
Process Base64EncodeChoreo;
|
TembooChoreo Base64EncodeChoreo;
|
||||||
|
|
||||||
// invoke the Temboo client
|
// invoke the Temboo client
|
||||||
Base64EncodeChoreo.begin("temboo");
|
Base64EncodeChoreo.begin();
|
||||||
|
|
||||||
// set Temboo account credentials
|
// set Temboo account credentials
|
||||||
Base64EncodeChoreo.addParameter("-a");
|
Base64EncodeChoreo.setAccountName(TEMBOO_ACCOUNT);
|
||||||
Base64EncodeChoreo.addParameter(TEMBOO_ACCOUNT);
|
Base64EncodeChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
|
||||||
Base64EncodeChoreo.addParameter("-u");
|
Base64EncodeChoreo.setAppKey(TEMBOO_APP_KEY);
|
||||||
Base64EncodeChoreo.addParameter(TEMBOO_APP_KEY_NAME);
|
|
||||||
Base64EncodeChoreo.addParameter("-p");
|
|
||||||
Base64EncodeChoreo.addParameter(TEMBOO_APP_KEY);
|
|
||||||
|
|
||||||
// identify the Temboo Library choreo to run (Utilities > Encoding > Base64Encode)
|
// identify the Temboo Library choreo to run (Utilities > Encoding > Base64Encode)
|
||||||
Base64EncodeChoreo.addParameter("-c");
|
Base64EncodeChoreo.setChoreo("/Library/Utilities/Encoding/Base64Encode");
|
||||||
Base64EncodeChoreo.addParameter("/Library/Utilities/Encoding/Base64Encode");
|
|
||||||
|
|
||||||
// set choreo inputs
|
// set choreo inputs
|
||||||
Base64EncodeChoreo.addParameter("-i");
|
Base64EncodeChoreo.addInput("Text", toEncode);
|
||||||
Base64EncodeChoreo.addParameter("Text:" + toEncode);
|
|
||||||
|
|
||||||
// run the choreo
|
// run the choreo
|
||||||
Base64EncodeChoreo.run();
|
Base64EncodeChoreo.run();
|
||||||
|
@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
GetYahooWeatherReport
|
|
||||||
|
|
||||||
Demonstrates making a request to the Yahoo! Weather API using the Temboo Arduino Yun SDK.
|
|
||||||
|
|
||||||
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
|
|
||||||
|
|
||||||
A Temboo account and application key are necessary to run all Temboo examples.
|
|
||||||
If you don't already have one, you can register for a free Temboo account at
|
|
||||||
http://www.temboo.com
|
|
||||||
|
|
||||||
This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
|
|
||||||
to the Internet.
|
|
||||||
|
|
||||||
Looking for another API? We've got over 100 in our Library!
|
|
||||||
|
|
||||||
This example code is in the public domain.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <Bridge.h>
|
|
||||||
#include <Temboo.h>
|
|
||||||
#include "TembooAccount.h" // contains Temboo account information
|
|
||||||
// as described in the footer comment below
|
|
||||||
|
|
||||||
|
|
||||||
// the address for which a weather forecast will be retrieved
|
|
||||||
String ADDRESS_FOR_FORECAST = "104 Franklin St., New York NY 10013";
|
|
||||||
|
|
||||||
int numRuns = 1; // execution count, so that this doesn't run forever
|
|
||||||
int maxRuns = 10; // max number of times the Yahoo WeatherByAddress Choreo should be run
|
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
Serial.begin(9600);
|
|
||||||
|
|
||||||
// for debugging, wait until a serial console is connected
|
|
||||||
delay(4000);
|
|
||||||
while(!Serial);
|
|
||||||
Bridge.begin();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop()
|
|
||||||
{
|
|
||||||
// while we haven't reached the max number of runs...
|
|
||||||
if (numRuns <= maxRuns) {
|
|
||||||
|
|
||||||
// print status
|
|
||||||
Serial.println("Running GetWeatherByAddress - Run #" + String(numRuns++) + "...");
|
|
||||||
|
|
||||||
// create a TembooChoreo object to send a Choreo request to Temboo
|
|
||||||
TembooChoreo GetWeatherByAddressChoreo;
|
|
||||||
|
|
||||||
// invoke the Temboo client
|
|
||||||
GetWeatherByAddressChoreo.begin();
|
|
||||||
|
|
||||||
// add your temboo account info
|
|
||||||
GetWeatherByAddressChoreo.setAccountName(TEMBOO_ACCOUNT);
|
|
||||||
GetWeatherByAddressChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
|
|
||||||
GetWeatherByAddressChoreo.setAppKey(TEMBOO_APP_KEY);
|
|
||||||
|
|
||||||
// set the name of the choreo we want to run
|
|
||||||
GetWeatherByAddressChoreo.setChoreo("/Library/Yahoo/Weather/GetWeatherByAddress");
|
|
||||||
|
|
||||||
// set choreo inputs; in this case, the address for which to retrieve weather data
|
|
||||||
// the Temboo client provides standardized calls to 100+ cloud APIs
|
|
||||||
GetWeatherByAddressChoreo.addInput("Address", ADDRESS_FOR_FORECAST);
|
|
||||||
|
|
||||||
// add an output filter to extract the name of the city.
|
|
||||||
GetWeatherByAddressChoreo.addOutputFilter("city", "/rss/channel/yweather:location/@city", "Response");
|
|
||||||
|
|
||||||
// add an output filter to extract the current temperature
|
|
||||||
GetWeatherByAddressChoreo.addOutputFilter("temperature", "/rss/channel/item/yweather:condition/@temp", "Response");
|
|
||||||
|
|
||||||
// add an output filter to extract the date and time of the last report.
|
|
||||||
GetWeatherByAddressChoreo.addOutputFilter("date", "/rss/channel/item/yweather:condition/@date", "Response");
|
|
||||||
|
|
||||||
// run the choreo
|
|
||||||
GetWeatherByAddressChoreo.run();
|
|
||||||
|
|
||||||
// when the choreo results are available, print them to the serial monitor
|
|
||||||
while(GetWeatherByAddressChoreo.available()) {
|
|
||||||
|
|
||||||
char c = GetWeatherByAddressChoreo.read();
|
|
||||||
Serial.print(c);
|
|
||||||
}
|
|
||||||
GetWeatherByAddressChoreo.close();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Serial.println("Waiting...");
|
|
||||||
Serial.println("");
|
|
||||||
delay(30000); // wait 30 seconds between GetWeatherByAddress calls
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
IMPORTANT NOTE: TembooAccount.h:
|
|
||||||
|
|
||||||
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
|
||||||
You'll need to edit the placeholder version of TembooAccount.h included with this example sketch,
|
|
||||||
by inserting your own Temboo account name and app key information. The contents of the file should
|
|
||||||
look like:
|
|
||||||
|
|
||||||
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
|
|
||||||
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
|
|
||||||
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
|
|
||||||
|
|
||||||
You can find your Temboo App Key information on the Temboo website,
|
|
||||||
under My Account > Application Keys
|
|
||||||
|
|
||||||
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
|
|
||||||
|
|
||||||
Keeping your account information in a separate file means you can save it once,
|
|
||||||
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
|
|
||||||
*/
|
|
@ -1,4 +0,0 @@
|
|||||||
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
|
|
||||||
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
|
|
||||||
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
|
|
||||||
|
|
Reference in New Issue
Block a user