Пример #1
0
int main() {

#error  remove this define + set the correct tokens before running this example

  Twitter tw;
  bool r =  tw.setup("466622389-...",  /* the token */
                     "eH25IAxRIB...",  /* the token secret */
                     "e0vURm6xhS...",  /* the consumer key */
                     "R7HfL0vgy...."); /* the consumer secret */


  if(!r) {
    RX_ERROR("Cannot setup the twitter obj");
    ::exit(EXIT_FAILURE);
  }

  TwitterStatusesFilter tw_filter;
  tw_filter.track("love");
  tw.apiStatusesFilter(tw_filter, twitter_filter_cb, NULL);
  
  while(true) {
    tw.update();
  }

  return 0;
};
Пример #2
0
int main() {
  
  Jansson config;
  if(!config.load("twitter.json", true)) {
    RX_ERROR("Cannot load the twitter.json file with the config tokens");
    ::exit(EXIT_FAILURE);
  }
  std::string access_token;
  std::string access_token_secret;
  std::string consumer_key;
  std::string consumer_secret;

  if(!config.getString("/access_token", access_token) 
     || !config.getString("/access_token_secret", access_token_secret)
     || !config.getString("/consumer_key", consumer_key)
     || !config.getString("/consumer_secret", consumer_secret))
    {
      RX_ERROR("Cannot find the correct values in the config file");
      ::exit(EXIT_FAILURE);
    }

  Twitter tw;
  bool r =  tw.setup(access_token, access_token_secret, consumer_key, consumer_secret);

  if(!r) {
    RX_ERROR("Cannot setup the twitter obj");
    ::exit(EXIT_FAILURE);
  }


#if 1
  TwitterStatusesFilter tw_filter;
  tw_filter.track("love,openframeworks"); // comma separated list of keywords to track
  tw.apiStatusesFilter(tw_filter, twitter_filter_cb, NULL);
#endif

#if 0
  // Follow users timeline
  TwitterStatusesUserTimeline tl;
  tl.count = 10;
  tw.apiStatusesUserTimeline(tl, twitter_usertimeline_cb, NULL);
#endif

  while(true) {
    tw.update();
  }

  return 0;
};