diff options
| author | Federico Fissore <f.fissore@arduino.cc> | 2013-07-08 15:09:09 +0200 | 
|---|---|---|
| committer | Federico Fissore <f.fissore@arduino.cc> | 2013-07-08 15:09:09 +0200 | 
| commit | acf38a634ab0f5530ca5f0b15bc4c474b1091195 (patch) | |
| tree | 70039a97db754ac391f50ff8048c2d42233170ee /libraries/Bridge/examples/Temboo/ReadATweet | |
| parent | 320116c2867f981b0292cd10f77e2a6a7c604f49 (diff) | |
updated temboo examples
Diffstat (limited to 'libraries/Bridge/examples/Temboo/ReadATweet')
| -rw-r--r-- | libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino | 94 | 
1 files changed, 28 insertions, 66 deletions
| diff --git a/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino b/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino index e420e28..b17346c 100644 --- a/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino +++ b/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino @@ -24,10 +24,7 @@  */  #include <Bridge.h> -#include <Console.h> -#include <FileIO.h> -#include <HttpClient.h> -#include <Process.h> +#include <Temboo.h>  #include "TembooAccount.h" // contains Temboo account information                             // as described in the footer comment below @@ -40,73 +37,59 @@ const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret";  const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key";  const String TWITTER_CONSUMER_SECRET = "your-twitter-consumer-secret"; -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 numRuns = 1;   // execution count, so this doesn't run forever +int maxRuns = 10;   // the max number of times the Twitter HomeTimeline Choreo should run  void setup() {    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);    Bridge.begin();  } -  void loop()  {    // while we haven't reached the max number of runs...    if (numRuns <= maxRuns) { - -    // print status -    Serial.println("Running ReadATweet - Run #" + String(numRuns++) + "..."); - -    // define the Process that will be used to call the "temboo" client             -    Process HomeTimelineChoreo; +    Serial.println("Running ReadATweet - Run #" + String(numRuns++)); -    // invoke the Temboo client -    HomeTimelineChoreo.begin("temboo"); +    TembooChoreo HomeTimelineChoreo; + +    // invoke the Temboo client. +    // NOTE that the client must be reinvoked, and repopulated with +    // appropriate arguments, each time its run() method is called. +    HomeTimelineChoreo.begin();      // set Temboo account credentials -    HomeTimelineChoreo.addParameter("-a"); -    HomeTimelineChoreo.addParameter(TEMBOO_ACCOUNT); -    HomeTimelineChoreo.addParameter("-u"); -    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) -    HomeTimelineChoreo.addParameter("-c"); -    HomeTimelineChoreo.addParameter("/Library/Twitter/Timelines/HomeTimeline"); +    HomeTimelineChoreo.setAccountName(TEMBOO_ACCOUNT); +    HomeTimelineChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); +    HomeTimelineChoreo.setAppKey(TEMBOO_APP_KEY); +    // tell the Temboo client which Choreo to run (Twitter > Timelines > HomeTimeline) +    HomeTimelineChoreo.setChoreo("/Library/Twitter/Timelines/HomeTimeline"); +     +          // set the required choreo inputs      // see https://www.temboo.com/library/Library/Twitter/Timelines/HomeTimeline/      // for complete details about the inputs for this Choreo -    HomeTimelineChoreo.addParameter("-i"); -    HomeTimelineChoreo.addParameter("Count:1");  // the max number of Tweets to return from each request -    -    // add the Twitter account information -    HomeTimelineChoreo.addParameter("-i"); -    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); -    +    HomeTimelineChoreo.addInput("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); +    HomeTimelineChoreo.addInput("ConsumerKey", TWITTER_CONSUMER_KEY);     +    HomeTimelineChoreo.addInput("ConsumerSecret", TWITTER_CONSUMER_SECRET); +      // next, we'll define two output filters that let us specify the       // elements of the response from Twitter that we want to receive.      // see the examples at http://www.temboo.com/arduino      // for more on using output filters      // we want the text of the tweet -    HomeTimelineChoreo.addParameter("-o"); -    HomeTimelineChoreo.addParameter("tweet:/[1]/text:Response"); +    HomeTimelineChoreo.addOutputFilter("tweet", "/[1]/text", "Response");      // and the name of the author -    HomeTimelineChoreo.addParameter("-o"); -    HomeTimelineChoreo.addParameter("author:/[1]/user/screen_name:Response"); +    HomeTimelineChoreo.addOutputFilter("author", "/[1]/user/screen_name", "Response");      // tell the Process to run and wait for the results. The  @@ -114,7 +97,7 @@ void loop()      // was able to send our request to the Temboo servers      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(returnCode == 0) {        String author; // a String to hold the tweet author's name @@ -160,30 +143,9 @@ void loop()      }      HomeTimelineChoreo.close(); +    }    Serial.println("Waiting..."); -  Serial.println("");    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. -*/ | 
