updated temboo examples
This commit is contained in:
parent
383199f468
commit
2c91f4895e
|
@ -25,6 +25,10 @@
|
||||||
#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
|
||||||
|
|
||||||
|
|
||||||
|
// the address for which a weather forecast will be retrieved
|
||||||
|
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 = 0; // 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
|
||||||
|
|
||||||
|
@ -32,6 +36,7 @@ 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);
|
||||||
while(!Serial);
|
while(!Serial);
|
||||||
Bridge.begin();
|
Bridge.begin();
|
||||||
}
|
}
|
||||||
|
@ -58,14 +63,14 @@ void loop()
|
||||||
GetWeatherByAddressChoreo.addParameter("-p");
|
GetWeatherByAddressChoreo.addParameter("-p");
|
||||||
GetWeatherByAddressChoreo.addParameter(TEMBOO_APP_KEY);
|
GetWeatherByAddressChoreo.addParameter(TEMBOO_APP_KEY);
|
||||||
|
|
||||||
// identify the Temboo Library choreo to run (Yahoo > Weather > GetWeatherByAddress)
|
// identify the Temboo Library choreo to run (Yahoo > Weather > GetWeatherByAddress)
|
||||||
GetWeatherByAddressChoreo.addParameter("-c");
|
GetWeatherByAddressChoreo.addParameter("-c");
|
||||||
GetWeatherByAddressChoreo.addParameter("/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.addParameter("-i");
|
||||||
GetWeatherByAddressChoreo.addParameter("Address:104 Franklin St., New York NY 10013");
|
GetWeatherByAddressChoreo.addParameter("Address:" + ADDRESS_FOR_FORECAST);
|
||||||
|
|
||||||
// run the choreo
|
// run the choreo
|
||||||
GetWeatherByAddressChoreo.run();
|
GetWeatherByAddressChoreo.run();
|
||||||
|
@ -76,34 +81,35 @@ void loop()
|
||||||
// note that in this example, we just print the raw XML response from Yahoo
|
// 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
|
// see the examples on using Temboo SDK output filters at http://www.temboo.com/arduino
|
||||||
// for information on how to filter this data
|
// for information on how to filter this data
|
||||||
|
char c = GetWeatherByAddressChoreo.read();
|
||||||
Serial.print((char)GetWeatherByAddressChoreo.read());
|
Serial.print(c);
|
||||||
}
|
}
|
||||||
GetWeatherByAddressChoreo.close();
|
GetWeatherByAddressChoreo.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("Sleeping...");
|
Serial.println("Waiting...");
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
delay(30000); // sleep 30 seconds between GetWeatherByAddress calls
|
delay(30000); // wait 30 seconds between GetWeatherByAddress calls
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
IMPORTANT NOTE: TembooAccount.h:
|
IMPORTANT NOTE: TembooAccount.h:
|
||||||
|
|
||||||
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
||||||
You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
|
You'll need to edit the placeholder version of TembooAccount.h included with this example sketch,
|
||||||
include the following variables and constants:
|
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_ACCOUNT "myTembooAccountName" // your Temboo account name
|
||||||
#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
|
||||||
|
|
||||||
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
|
|
||||||
|
|
||||||
You can find your Temboo App Key information on the Temboo website,
|
You can find your Temboo App Key information on the Temboo website,
|
||||||
under My Account > Application Keys
|
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,
|
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.
|
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#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
|
||||||
|
|
|
@ -33,12 +33,14 @@
|
||||||
|
|
||||||
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
|
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
|
||||||
|
|
||||||
|
// Note that for additional security and reusability, you could
|
||||||
|
// use #define statements to specify these values in a .h file.
|
||||||
const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token";
|
const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token";
|
||||||
const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret";
|
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 = 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 Twitter HomeTimeline Choreo should run
|
int maxRuns = 10; // the max number of times the Twitter HomeTimeline Choreo should run
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
@ -53,7 +55,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 ReadATweet - Run #" + String(numRuns++) + "...");
|
Serial.println("Running ReadATweet - Run #" + String(numRuns++) + "...");
|
||||||
|
@ -108,12 +110,12 @@ void loop()
|
||||||
|
|
||||||
|
|
||||||
// tell the Process to run and wait for the results. The
|
// tell the Process to run and wait for the results. The
|
||||||
// return code (rc) will tell us whether the Temboo client
|
// return code 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 rc = HomeTimelineChoreo.run();
|
unsigned int returnCode = HomeTimelineChoreo.run();
|
||||||
|
|
||||||
// a response code of 0 means success; print the API response
|
// a response code of 0 means success; print the API response
|
||||||
if(rc == 0) {
|
if(returnCode == 0) {
|
||||||
|
|
||||||
String author; // a String to hold the tweet author's name
|
String author; // a String to hold the tweet author's name
|
||||||
String tweet; // a String to hold the text of the tweet
|
String tweet; // a String to hold the text of the tweet
|
||||||
|
@ -152,34 +154,36 @@ void loop()
|
||||||
// there was an error
|
// there was an error
|
||||||
// print the raw output from the choreo
|
// print the raw output from the choreo
|
||||||
while(HomeTimelineChoreo.available()) {
|
while(HomeTimelineChoreo.available()) {
|
||||||
Serial.print((char)HomeTimelineChoreo.read());
|
char c = HomeTimelineChoreo.read();
|
||||||
|
Serial.print(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HomeTimelineChoreo.close();
|
HomeTimelineChoreo.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("Sleeping...");
|
Serial.println("Waiting...");
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
delay(90000); // sleep 90 seconds between HomeTimeline calls
|
delay(90000); // wait 90 seconds between HomeTimeline calls
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
IMPORTANT NOTE: TembooAccount.h:
|
IMPORTANT NOTE: TembooAccount.h:
|
||||||
|
|
||||||
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
||||||
You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
|
You'll need to edit the placeholder version of TembooAccount.h included with this example sketch,
|
||||||
include the following variables and constants:
|
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_ACCOUNT "myTembooAccountName" // your Temboo account name
|
||||||
#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
|
||||||
|
|
||||||
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
|
|
||||||
|
|
||||||
You can find your Temboo App Key information on the Temboo website,
|
You can find your Temboo App Key information on the Temboo website,
|
||||||
under My Account > Application Keys
|
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,
|
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.
|
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#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
|
||||||
|
|
|
@ -10,8 +10,10 @@
|
||||||
http://www.temboo.com
|
http://www.temboo.com
|
||||||
|
|
||||||
In order to run this sketch, you'll need to register an application using
|
In order to run this sketch, you'll need to register an application using
|
||||||
the Twitter dev console at https://dev.twitter.com. After creating the
|
the Twitter dev console at https://dev.twitter.com. Note that since this
|
||||||
app, you'll find OAuth credentials for that application under the "OAuth Tool" tab.
|
sketch creates a new tweet, your application will need to be configured with
|
||||||
|
read+write permissions. After creating the app, you'll find OAuth credentials
|
||||||
|
for that application under the "OAuth Tool" tab.
|
||||||
Substitute these values for the placeholders below.
|
Substitute these values for the placeholders below.
|
||||||
|
|
||||||
This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
|
This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
|
||||||
|
@ -33,6 +35,8 @@
|
||||||
|
|
||||||
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
|
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
|
||||||
|
|
||||||
|
// Note that for additional security and reusability, you could
|
||||||
|
// use #define statements to specify these values in a .h file.
|
||||||
const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token";
|
const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token";
|
||||||
const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret";
|
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";
|
||||||
|
@ -72,7 +76,7 @@ void loop()
|
||||||
StatusesUpdateChoreo.addParameter("-p");
|
StatusesUpdateChoreo.addParameter("-p");
|
||||||
StatusesUpdateChoreo.addParameter(TEMBOO_APP_KEY);
|
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.addParameter("-c");
|
||||||
StatusesUpdateChoreo.addParameter("/Library/Twitter/Tweets/StatusesUpdate");
|
StatusesUpdateChoreo.addParameter("/Library/Twitter/Tweets/StatusesUpdate");
|
||||||
|
|
||||||
|
@ -96,24 +100,25 @@ void loop()
|
||||||
StatusesUpdateChoreo.addParameter("StatusUpdate:" + tweet);
|
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 (rc) 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 rc = StatusesUpdateChoreo.run();
|
unsigned int returnCode = StatusesUpdateChoreo.run();
|
||||||
|
|
||||||
// a return code of zero (0) means everything worked
|
// a return code of zero (0) means everything worked
|
||||||
if (rc == 0) {
|
if (returnCode == 0) {
|
||||||
Serial.println("Success! Tweet sent!");
|
Serial.println("Success! Tweet sent!");
|
||||||
} else {
|
} else {
|
||||||
// a non-zero return code means there was an error
|
// a non-zero return code means there was an error
|
||||||
// read and print the error message
|
// read and print the error message
|
||||||
while (StatusesUpdateChoreo.available()) {
|
while (StatusesUpdateChoreo.available()) {
|
||||||
Serial.print((char)StatusesUpdateChoreo.read());
|
char c = StatusesUpdateChoreo.read();
|
||||||
|
Serial.print(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StatusesUpdateChoreo.close();
|
StatusesUpdateChoreo.close();
|
||||||
|
|
||||||
// do nothing for the next 90 seconds
|
// do nothing for the next 90 seconds
|
||||||
Serial.println("Sleeping...");
|
Serial.println("Waiting...");
|
||||||
delay(90000);
|
delay(90000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,22 +126,22 @@ void loop()
|
||||||
/*
|
/*
|
||||||
IMPORTANT NOTE: TembooAccount.h:
|
IMPORTANT NOTE: TembooAccount.h:
|
||||||
|
|
||||||
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
||||||
You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
|
You'll need to edit the placeholder version of TembooAccount.h included with this example sketch,
|
||||||
include the following variables and constants:
|
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_ACCOUNT "myTembooAccountName" // your Temboo account name
|
||||||
#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
|
||||||
|
|
||||||
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
|
|
||||||
|
|
||||||
You can find your Temboo App Key information on the Temboo website,
|
You can find your Temboo App Key information on the Temboo website,
|
||||||
under My Account > Application Keys
|
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,
|
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.
|
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#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
|
||||||
|
|
|
@ -31,6 +31,9 @@
|
||||||
|
|
||||||
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
|
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
|
||||||
|
|
||||||
|
// 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 address, eg "bob.smith@gmail.com"
|
||||||
const String GMAIL_USER_NAME = "xxxxxxxxxx";
|
const String GMAIL_USER_NAME = "xxxxxxxxxx";
|
||||||
|
|
||||||
|
@ -74,7 +77,7 @@ void loop()
|
||||||
SendEmailChoreo.addParameter("-p");
|
SendEmailChoreo.addParameter("-p");
|
||||||
SendEmailChoreo.addParameter(TEMBOO_APP_KEY);
|
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.addParameter("-c");
|
||||||
SendEmailChoreo.addParameter("/Library/Google/Gmail/SendEmail");
|
SendEmailChoreo.addParameter("/Library/Google/Gmail/SendEmail");
|
||||||
|
|
||||||
|
@ -103,19 +106,20 @@ void loop()
|
||||||
SendEmailChoreo.addParameter("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 Process to run and wait for the results. The
|
||||||
// return code (rc) 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 rc = SendEmailChoreo.run();
|
unsigned int returnCode = SendEmailChoreo.run();
|
||||||
|
|
||||||
// a return code of zero (0) means everything worked
|
// a return code of zero (0) means everything worked
|
||||||
if (rc == 0) {
|
if (returnCode == 0) {
|
||||||
Serial.println("Success! Email sent!");
|
Serial.println("Success! Email sent!");
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
// a non-zero return code means there was an error
|
// a non-zero return code means there was an error
|
||||||
// read and print the error message
|
// read and print the error message
|
||||||
while (SendEmailChoreo.available()) {
|
while (SendEmailChoreo.available()) {
|
||||||
Serial.print((char)SendEmailChoreo.read());
|
char c = SendEmailChoreo.read();
|
||||||
|
Serial.print(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SendEmailChoreo.close();
|
SendEmailChoreo.close();
|
||||||
|
@ -128,20 +132,20 @@ void loop()
|
||||||
/*
|
/*
|
||||||
IMPORTANT NOTE: TembooAccount.h:
|
IMPORTANT NOTE: TembooAccount.h:
|
||||||
|
|
||||||
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
||||||
You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
|
You'll need to edit the placeholder version of TembooAccount.h included with this example sketch,
|
||||||
include the following variables and constants:
|
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_ACCOUNT "myTembooAccountName" // your Temboo account name
|
||||||
#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
|
||||||
|
|
||||||
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
|
|
||||||
|
|
||||||
You can find your Temboo App Key information on the Temboo website,
|
You can find your Temboo App Key information on the Temboo website,
|
||||||
under My Account > Application Keys
|
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,
|
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.
|
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#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
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,9 @@
|
||||||
|
|
||||||
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
|
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
|
||||||
|
|
||||||
|
// Note that for additional security and reusability, you could
|
||||||
|
// use #define statements to specify these values in a .h file.
|
||||||
|
|
||||||
// the Account SID from your Twilio account
|
// the Account SID from your Twilio account
|
||||||
const String TWILIO_ACCOUNT_SID = "xxxxxxxxxx";
|
const String TWILIO_ACCOUNT_SID = "xxxxxxxxxx";
|
||||||
|
|
||||||
|
@ -116,25 +119,26 @@ void loop()
|
||||||
SendSMSChoreo.addParameter("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 (rc) 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 rc = SendSMSChoreo.run();
|
unsigned int returnCode = SendSMSChoreo.run();
|
||||||
|
|
||||||
// a return code of zero (0) means everything worked
|
// a return code of zero (0) means everything worked
|
||||||
if (rc == 0) {
|
if (returnCode == 0) {
|
||||||
Serial.println("Success! SMS sent!");
|
Serial.println("Success! SMS sent!");
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
// a non-zero return code means there was an error
|
// a non-zero return code means there was an error
|
||||||
// read and print the error message
|
// read and print the error message
|
||||||
while (SendSMSChoreo.available()) {
|
while (SendSMSChoreo.available()) {
|
||||||
Serial.print((char)SendSMSChoreo.read());
|
char c = SendSMSChoreo.read();
|
||||||
|
Serial.print(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SendSMSChoreo.close();
|
SendSMSChoreo.close();
|
||||||
|
|
||||||
// do nothing for the next 60 seconds
|
// do nothing for the next 60 seconds
|
||||||
Serial.println("Sleeping...");
|
Serial.println("Waiting...");
|
||||||
delay(60000);
|
delay(60000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,19 +146,20 @@ void loop()
|
||||||
/*
|
/*
|
||||||
IMPORTANT NOTE: TembooAccount.h:
|
IMPORTANT NOTE: TembooAccount.h:
|
||||||
|
|
||||||
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
||||||
You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
|
You'll need to edit the placeholder version of TembooAccount.h included with this example sketch,
|
||||||
include the following variables and constants:
|
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_ACCOUNT "myTembooAccountName" // your Temboo account name
|
||||||
#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
|
||||||
|
|
||||||
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
|
|
||||||
|
|
||||||
You can find your Temboo App Key information on the Temboo website,
|
You can find your Temboo App Key information on the Temboo website,
|
||||||
under My Account > Application Keys
|
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,
|
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.
|
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#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
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,8 @@
|
||||||
work properly. It doesn't matter what the column labels actually are,
|
work properly. It doesn't matter what the column labels actually are,
|
||||||
but there must be text in the first row of each column. This example
|
but there must be text in the first row of each column. This example
|
||||||
assumes there are two columns. The first column is the time (in milliseconds)
|
assumes there are two columns. The first column is the time (in milliseconds)
|
||||||
that the row was appended, and the second column is a sensor value
|
that the row was appended, and the second column is a sensor value.
|
||||||
(simulated in this example via a random number). In other words, your spreadsheet
|
In other words, your spreadsheet should look like:
|
||||||
should look like:
|
|
||||||
|
|
||||||
Time | Sensor Value |
|
Time | Sensor Value |
|
||||||
------+-----------------
|
------+-----------------
|
||||||
|
@ -48,13 +47,18 @@
|
||||||
|
|
||||||
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
|
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
|
||||||
|
|
||||||
|
// Note that for additional security and reusability, you could
|
||||||
|
// use #define statements to specify these values in a .h file.
|
||||||
|
|
||||||
const String GOOGLE_USERNAME = "your-google-username";
|
const String GOOGLE_USERNAME = "your-google-username";
|
||||||
const String GOOGLE_PASSWORD = "your-google-password";
|
const String GOOGLE_PASSWORD = "your-google-password";
|
||||||
|
|
||||||
// the title of the spreadsheet you want to send data to
|
// the title of the spreadsheet you want to send data to
|
||||||
|
// (Note that this must actually be the title of a Google spreadsheet
|
||||||
|
// that exists in your Google Drive/Docs account, and is configured
|
||||||
|
// as described above.)
|
||||||
const String SPREADSHEET_TITLE = "your-spreadsheet-title";
|
const String SPREADSHEET_TITLE = "your-spreadsheet-title";
|
||||||
|
|
||||||
|
|
||||||
const unsigned long RUN_INTERVAL_MILLIS = 60000; // how often to run the Choreo (in milliseconds)
|
const unsigned long RUN_INTERVAL_MILLIS = 60000; // how often to run the Choreo (in milliseconds)
|
||||||
|
|
||||||
// the last time we ran the Choreo
|
// the last time we ran the Choreo
|
||||||
|
@ -137,18 +141,19 @@ void loop()
|
||||||
AppendRowChoreo.addParameter("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 (rc) will indicate success or failure
|
// The return code (returnCode) will indicate success or failure
|
||||||
unsigned int rc = AppendRowChoreo.run();
|
unsigned int returnCode = AppendRowChoreo.run();
|
||||||
|
|
||||||
// return code of zero (0) means success
|
// return code of zero (0) means success
|
||||||
if (rc == 0) {
|
if (returnCode == 0) {
|
||||||
Serial.println("Success! Appended " + rowData);
|
Serial.println("Success! Appended " + rowData);
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
} else {
|
} else {
|
||||||
// return code of anything other than zero means failure
|
// return code of anything other than zero means failure
|
||||||
// read and display any error messages
|
// read and display any error messages
|
||||||
while (AppendRowChoreo.available()) {
|
while (AppendRowChoreo.available()) {
|
||||||
Serial.print((char)AppendRowChoreo.read());
|
char c = AppendRowChoreo.read();
|
||||||
|
Serial.print(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,28 +162,27 @@ void loop()
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function simulates reading the value of a sensor
|
// this function simulates reading the value of a sensor
|
||||||
// in this example, we're generating a random number
|
|
||||||
unsigned long getSensorValue() {
|
unsigned long getSensorValue() {
|
||||||
return (unsigned long)random(0, 256);
|
return analogRead(A0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
IMPORTANT NOTE: TembooAccount.h:
|
IMPORTANT NOTE: TembooAccount.h:
|
||||||
|
|
||||||
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
||||||
You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
|
You'll need to edit the placeholder version of TembooAccount.h included with this example sketch,
|
||||||
include the following variables and constants:
|
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_ACCOUNT "myTembooAccountName" // your Temboo account name
|
||||||
#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
|
||||||
|
|
||||||
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
|
|
||||||
|
|
||||||
You can find your Temboo App Key information on the Temboo website,
|
You can find your Temboo App Key information on the Temboo website,
|
||||||
under My Account > Application Keys
|
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,
|
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.
|
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#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
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#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
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
#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
|
||||||
|
|
||||||
// the zip code to search
|
// the zip code to search for toxin-emitting facilities
|
||||||
const String US_ZIP_CODE = "11215";
|
String US_ZIP_CODE = "11215";
|
||||||
|
|
||||||
int numRuns = 1; // 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 Envirofacts FacilitiesSearch Choreo should be run
|
int maxRuns = 10; // max number of times the Envirofacts FacilitiesSearch Choreo should be run
|
||||||
|
@ -82,93 +82,98 @@ void loop()
|
||||||
FacilitiesSearchByZipChoreo.addParameter("addr:STREET_ADDRESS:Response");
|
FacilitiesSearchByZipChoreo.addParameter("addr:STREET_ADDRESS:Response");
|
||||||
|
|
||||||
// run the choreo
|
// run the choreo
|
||||||
FacilitiesSearchByZipChoreo.run();
|
unsigned int returnCode = FacilitiesSearchByZipChoreo.run();
|
||||||
|
if (returnCode == 0) {
|
||||||
String facs;
|
String facilities;
|
||||||
String addrs;
|
String addresses;
|
||||||
|
|
||||||
// when the choreo results are available, process them.
|
// when the choreo results are available, process them.
|
||||||
// the output filters we specified will return comma delimited
|
// the output filters we specified will return comma delimited
|
||||||
// lists containing the name and street address of the facilities
|
// lists containing the name and street address of the facilities
|
||||||
// located in the specified zip code.
|
// located in the specified zip code.
|
||||||
while(FacilitiesSearchByZipChoreo.available()) {
|
while(FacilitiesSearchByZipChoreo.available()) {
|
||||||
String name = FacilitiesSearchByZipChoreo.readStringUntil('\x1F');
|
String name = FacilitiesSearchByZipChoreo.readStringUntil('\x1F');
|
||||||
name.trim();
|
name.trim();
|
||||||
|
|
||||||
String data = FacilitiesSearchByZipChoreo.readStringUntil('\x1E');
|
String data = FacilitiesSearchByZipChoreo.readStringUntil('\x1E');
|
||||||
data.trim();
|
data.trim();
|
||||||
|
|
||||||
if (name == "fac") {
|
if (name == "fac") {
|
||||||
facs = data;
|
facilities = data;
|
||||||
} else if (name == "addr") {
|
} else if (name == "addr") {
|
||||||
addrs = data;
|
addresses = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FacilitiesSearchByZipChoreo.close();
|
||||||
|
|
||||||
|
// parse the comma delimited lists of facilities to join the
|
||||||
|
// name with the address and print it to the serial monitor
|
||||||
|
if (facilities.length() > 0) {
|
||||||
|
int i = -1;
|
||||||
|
int facilityStart = 0;
|
||||||
|
int addressStart = 0;
|
||||||
|
String facility;
|
||||||
|
String address;
|
||||||
|
do {
|
||||||
|
i = facilities.indexOf(',', facilityStart);
|
||||||
|
if (i >= 0) {
|
||||||
|
facility = facilities.substring(facilityStart, i);
|
||||||
|
facilityStart = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = addresses.indexOf(',', addressStart);
|
||||||
|
if (i >= 0) {
|
||||||
|
address = addresses.substring(addressStart, i);
|
||||||
|
addressStart = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i >= 0) {
|
||||||
|
printResult(facility, address);
|
||||||
|
}
|
||||||
|
|
||||||
|
}while (i >= 0);
|
||||||
|
facility = facilities.substring(facilityStart);
|
||||||
|
address = addresses.substring(addressStart);
|
||||||
|
printResult(facility, address);
|
||||||
|
} else {
|
||||||
|
Serial.println("No facilities found in zip code " + US_ZIP_CODE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while(FacilitiesSearchByZipChoreo.available()) {
|
||||||
|
char c = FacilitiesSearchByZipChoreo.read();
|
||||||
|
Serial.print(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FacilitiesSearchByZipChoreo.close();
|
|
||||||
|
|
||||||
// parse the comma delimited lists of facilities to join the
|
|
||||||
// name with the address and print it to the serial monitor
|
|
||||||
if (facs.length() > 0) {
|
|
||||||
int i = -1;
|
|
||||||
int fstart = 0;
|
|
||||||
int astart = 0;
|
|
||||||
String f;
|
|
||||||
String a;
|
|
||||||
do {
|
|
||||||
i = facs.indexOf(',', fstart);
|
|
||||||
if (i >= 0) {
|
|
||||||
f = facs.substring(fstart, i);
|
|
||||||
fstart = i + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = addrs.indexOf(',', astart);
|
|
||||||
if (i >= 0) {
|
|
||||||
a = addrs.substring(astart, i);
|
|
||||||
astart = i + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i >= 0) {
|
|
||||||
printResult(f, a);
|
|
||||||
}
|
|
||||||
|
|
||||||
}while (i >= 0);
|
|
||||||
f = facs.substring(fstart);
|
|
||||||
a = addrs.substring(astart);
|
|
||||||
printResult(f, a);
|
|
||||||
} else {
|
|
||||||
Serial.println("No facilities found in zip code " + US_ZIP_CODE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Serial.println("Waiting...");
|
||||||
Serial.println("Sleeping...");
|
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
delay(30000); // sleep 30 seconds between calls
|
delay(30000); // wait 30 seconds between calls
|
||||||
}
|
}
|
||||||
|
|
||||||
// a simple utility function, to output the facility name and address in the serial monitor.
|
// a simple utility function, to output the facility name and address in the serial monitor.
|
||||||
void printResult(String fac, String addr) {
|
void printResult(String facility, String address) {
|
||||||
Serial.print(fac);
|
Serial.print(facility);
|
||||||
Serial.print(" - ");
|
Serial.print(" - ");
|
||||||
Serial.println(addr);
|
Serial.println(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
IMPORTANT NOTE: TembooAccount.h:
|
IMPORTANT NOTE: TembooAccount.h:
|
||||||
|
|
||||||
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
||||||
You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
|
You'll need to edit the placeholder version of TembooAccount.h included with this example sketch,
|
||||||
include the following variables and constants:
|
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_ACCOUNT "myTembooAccountName" // your Temboo account name
|
||||||
#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
|
||||||
|
|
||||||
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
|
|
||||||
|
|
||||||
You can find your Temboo App Key information on the Temboo website,
|
You can find your Temboo App Key information on the Temboo website,
|
||||||
under My Account > Application Keys
|
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,
|
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.
|
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#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
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
http://www.temboo.com
|
http://www.temboo.com
|
||||||
|
|
||||||
In order to run this sketch, you'll need to register an application using
|
In order to run this sketch, you'll need to register an application using
|
||||||
the Facebook dev console at https://developers.facebook.com/apps. After creating
|
the Facebook dev console at https://developers.facebook.com/apps -- after creating
|
||||||
the app, log in to Temboo and visit https://www.temboo.com/library/Library/Facebook/Publishing/SetStatus/
|
the app, log in to Temboo and visit https://www.temboo.com/library/Library/Facebook/Publishing/SetStatus/
|
||||||
to use our OAuth Wizard (or OAuth Choreos) to obtain a Facebook access token.
|
to use our OAuth Wizard (or OAuth Choreos) to obtain a Facebook access token.
|
||||||
Substitute your access token for the placeholder value of FACEBOOK_ACCESS_TOKEN below.
|
Substitute your access token for the placeholder value of FACEBOOK_ACCESS_TOKEN below.
|
||||||
|
@ -33,6 +33,9 @@
|
||||||
|
|
||||||
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
|
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
|
||||||
|
|
||||||
|
// Note that for additional security and reusability, you could
|
||||||
|
// use a #define statement to specify this value in a .h file.
|
||||||
|
|
||||||
// the Facebook Access Token, which can be obtained using the Temboo OAuth Wizard or Choreos
|
// the Facebook Access Token, which can be obtained using the Temboo OAuth Wizard or Choreos
|
||||||
const String FACEBOOK_ACCESS_TOKEN = "xxxxxxxxxx";
|
const String FACEBOOK_ACCESS_TOKEN = "xxxxxxxxxx";
|
||||||
|
|
||||||
|
@ -89,45 +92,47 @@ void loop() {
|
||||||
|
|
||||||
|
|
||||||
// tell the Process to run and wait for the results. The
|
// tell the Process to run and wait for the results. The
|
||||||
// return code (rc) 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 rc = SetStatusChoreo.run();
|
unsigned int returnCode = SetStatusChoreo.run();
|
||||||
|
|
||||||
// print the response code and API response.
|
// print the response code and API response.
|
||||||
Serial.println("Resonse code: " + String(rc));
|
Serial.println("Response code: " + String(returnCode));
|
||||||
|
|
||||||
// note that in this case, we're just printing the raw response from Facebook.
|
// note that in this case, we're just printing the raw response from Facebook.
|
||||||
// see the examples on using Temboo SDK output filters at http://www.temboo.com/arduino
|
// see the examples on using Temboo SDK output filters at http://www.temboo.com/arduino
|
||||||
// for information on how to filter this data
|
// for information on how to filter this data
|
||||||
while(SetStatusChoreo.available()) {
|
while(SetStatusChoreo.available()) {
|
||||||
Serial.print((char)SetStatusChoreo.read());
|
char c = SetStatusChoreo.read();
|
||||||
|
Serial.print(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetStatusChoreo.close();
|
SetStatusChoreo.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("Sleeping...");
|
Serial.println("Waiting...");
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
|
|
||||||
delay(30000); // sleep 30 seconds between SetStatus calls
|
delay(30000); // wait 30 seconds between SetStatus calls
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
IMPORTANT NOTE: TembooAccount.h:
|
IMPORTANT NOTE: TembooAccount.h:
|
||||||
|
|
||||||
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
||||||
You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
|
You'll need to edit the placeholder version of TembooAccount.h included with this example sketch,
|
||||||
include the following variables and constants:
|
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_ACCOUNT "myTembooAccountName" // your Temboo account name
|
||||||
#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
|
||||||
|
|
||||||
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
|
|
||||||
|
|
||||||
You can find your Temboo App Key information on the Temboo website,
|
You can find your Temboo App Key information on the Temboo website,
|
||||||
under My Account > Application Keys
|
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,
|
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.
|
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#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
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
|
|
||||||
You'll also need a valid Dropbox account, and OAuth credentials for Dropbox. To
|
You'll also need a valid Dropbox account, and OAuth credentials for Dropbox. To
|
||||||
obtain OAuth credentials for Dropbox, you'll need to register a Dropbox app at
|
obtain OAuth credentials for Dropbox, you'll need to register a Dropbox app at
|
||||||
https://www.dropbox.com/developers/apps and then follow the instructions at
|
https://www.dropbox.com/developers/apps -- the app name and domain can be whatever
|
||||||
|
you'd like. After registering the app, follow the instructions at
|
||||||
https://www.temboo.com/library/Library/Dropbox/OAuth/ to run the Initialize and Finalize
|
https://www.temboo.com/library/Library/Dropbox/OAuth/ to run the Initialize and Finalize
|
||||||
OAuth Choreos to complete the OAuth handshake and retrieve your Access Token information.
|
OAuth Choreos to complete the OAuth handshake and retrieve your Access Token information.
|
||||||
|
|
||||||
|
@ -34,6 +35,9 @@
|
||||||
|
|
||||||
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
|
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
|
||||||
|
|
||||||
|
// Note that for additional security and reusability, you could
|
||||||
|
// use #define statements to specify these values in a .h file.
|
||||||
|
|
||||||
// your Dropbox app key, available on the Dropbox developer console after registering an app
|
// your Dropbox app key, available on the Dropbox developer console after registering an app
|
||||||
const String DROPBOX_APP_KEY = "xxxxxxxxxx";
|
const String DROPBOX_APP_KEY = "xxxxxxxxxx";
|
||||||
|
|
||||||
|
@ -117,12 +121,12 @@ void loop()
|
||||||
UploadFileChoreo.addParameter("AppKey:" + DROPBOX_APP_KEY);
|
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 (rc) 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 rc = UploadFileChoreo.run();
|
unsigned int returnCode = UploadFileChoreo.run();
|
||||||
|
|
||||||
// a return code of zero (0) means everything worked
|
// a return code of zero (0) means everything worked
|
||||||
if (rc == 0) {
|
if (returnCode == 0) {
|
||||||
Serial.println("Success! File uploaded!");
|
Serial.println("Success! File uploaded!");
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -133,14 +137,15 @@ void loop()
|
||||||
// print out the full response to the serial monitor in all
|
// print out the full response to the serial monitor in all
|
||||||
// cases, just for debugging
|
// cases, just for debugging
|
||||||
while (UploadFileChoreo.available()) {
|
while (UploadFileChoreo.available()) {
|
||||||
Serial.print((char)UploadFileChoreo.read());
|
char c = UploadFileChoreo.read();
|
||||||
|
Serial.print(c);
|
||||||
}
|
}
|
||||||
UploadFileChoreo.close();
|
UploadFileChoreo.close();
|
||||||
|
|
||||||
Serial.println("Sleeping...");
|
Serial.println("Waiting...");
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(30000); // sleep 30 seconds between upload attempts
|
delay(30000); // wait 30 seconds between upload attempts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,20 +198,22 @@ String base64Encode(String toEncode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
IMPORTANT NOTE About TembooAccount.h:
|
IMPORTANT NOTE: TembooAccount.h:
|
||||||
|
|
||||||
TembooAccount.h is not included with this example because it contains your account information.
|
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
|
||||||
You need to create it for your own version of this application. To do so, make
|
You'll need to edit the placeholder version of TembooAccount.h included with this example sketch,
|
||||||
a new tab in Arduino, call it TembooAccount.h, and include the following variables and constants:
|
by inserting your own Temboo account name and app key information. The contents of the file should
|
||||||
|
look like:
|
||||||
|
|
||||||
#define TEMBOO_ACCOUNT "matthew-yun" // your Temboo account name
|
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
|
||||||
#define TEMBOO_APP_KEY_NAME "someKey" // your Temboo app key name
|
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
|
||||||
#define TEMBOO_APP_KEY "fveIrkjAVIkuNUUPE6df" // your Temboo app key
|
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
|
||||||
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
|
|
||||||
|
|
||||||
You can find your Temboo App Key information on the Temboo website,
|
You can find your Temboo App Key information on the Temboo website,
|
||||||
under My Account > Application Keys
|
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,
|
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.
|
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue