Hello
I'm doing a search on Twitter using the library temboo.But somehow I could not parse process. I want to get the ID from the most recent tweet..When I run the following code, nothing happens to the pars.Are you going to help in this regard.
Sorry for bad english
#include <SPI.h>
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <Temboo.h>
#include "TembooAccount.h" // Contains Temboo account information
#include <aJSON.h>
byte ethernetMACAddress[] = ETHERNET_SHIELD_MAC;
EthernetClient client;
int numRuns = 1; // Execution count, so this doesn't run forever
int maxRuns = 10; // Maximum number of times the Choreo should be executed
//char* parseJson(char *jsonString) ;
char jsonstring1[] = "" ;
char jsonstring2[] = "" ;
char jsonstring3[] = "" ;
int counter = 0;
void setup() {
Serial.begin(9600);
// For debugging, wait until the serial console is connected.
delay(1000);
while(!Serial);
//char* value = parseJson(jsonString);
Serial.print("DHCP:");
if (Ethernet.begin(ethernetMACAddress) == 0) {
Serial.println("FAIL");
while(true);
}
Serial.println("OK");
delay(2000);
Serial.println("Setup complete.\n");
}
String command;
void loop() {
if (numRuns <= maxRuns) {
Serial.println("Running Tweets - Run #" + String(numRuns++));
TembooChoreo TweetsChoreo(client);
// Invoke the Temboo client
TweetsChoreo.begin();
// Set Temboo account credentials
TweetsChoreo.setAccountName(TEMBOO_ACCOUNT);
TweetsChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
TweetsChoreo.setAppKey(TEMBOO_APP_KEY);
// Set Choreo inputs
String CountValue = "1";
TweetsChoreo.addInput("Count", CountValue);
String AccessTokenValue = "";
TweetsChoreo.addInput("AccessToken", AccessTokenValue);
String QueryValue = "#colorbits";
TweetsChoreo.addInput("Query", QueryValue);
String AccessTokenSecretValue = "";
TweetsChoreo.addInput("AccessTokenSecret", AccessTokenSecretValue);
String ConsumerSecretValue = "";
TweetsChoreo.addInput("ConsumerSecret", ConsumerSecretValue);
String ConsumerKeyValue = "";
TweetsChoreo.addInput("ConsumerKey", ConsumerKeyValue);
String ResultTypeValue = "recent";
TweetsChoreo.addInput("ResultType", ResultTypeValue);
// Identify the Choreo to run
TweetsChoreo.setChoreo("/Library/Twitter/Search/Tweets");
// Run the Choreo; when results are available, print them to serial
TweetsChoreo.run();
counter = 0;
while(TweetsChoreo.available()) {
char c = TweetsChoreo.read();
Serial.print(c);
if(counter < 1000) {
jsonstring1[counter] = c;
}
else if(counter > 1000){
jsonstring2[counter] = c;
} else if(counter > 2000){
jsonstring3[counter] = c;
}
aJsonObject* root = aJson.parse(jsonstring1);
aJsonObject* statuses = aJson.getObjectItem(root, "statuses");
aJsonObject* status0 = aJson.getArrayItem(statuses, 0);
aJsonObject* tweetId = aJson.getObjectItem(status0, "id");
String tweetIdStr = tweetId->valuestring;
Serial.print("ID : ");
Serial.println(tweetIdStr);
}
counter++;
TweetsChoreo.close();
}
Serial.println("\nWaiting...\n");
delay(5000);
}