ofxTwitterstream example > doesn't work

I’m trying to fetch tweets with a certain hashtag. I ran into the ofxTwitterstream addon but when trying to run the example I am confused what’s going wrong. I used a couple of very common hashtags but it doesn’t return anything. I’m not even sure if the login is successful or anything.
can anyone help?

void testApp::setup(){
		"my username"
		,"my pw"

void testApp::update(){
	while(twitter.hasNewTweets()) {
		ofxTweet t = twitter.getNextTweet();
        printf("text %s", t.getText().c_str());
		cout << "avatar:" << t.getAvatar() << endl;
		cout << "---" << endl;

@suse_m i’m quite sure that ofxTwitterStream addon use the old Twitter Api, i suggest to you the ofxTwitter @pelayo addon, it works fine give a try it!

1 Like

I’ve actually started trying this before I posted the question but I cannot get the search example to work either.
is there a way to check if twitterClient.authorize(CONSUMER_KEY, CONSUMER_SECRET); is successful or not? the search example loads from cached file (twitterClient.loadCacheFile();) but not even the simple search // Simple Query. You can find tweets containing that word. ofxTwitterSearch search; search.query = "cat"; twitterClient.startSearch(search);

It works fine for me. Are you sure that you put the right keys? if the app is authorized a new browser page will open and you will redirect to the twitter server asked to authorize your application. After that it will stored in bin/data folder a credentials.xml file for the next use of your app. I think you can query if the app is auhorized with

bool ofxTwitter::isAuthorized()

but maybe @pelayo can give some more hints on it.

I entered a new app into dev.twitter.com and copypasted the codes. however, for me the openframeworks app doesn’t open a browser page which redirects to twitter… is that what you meant should happen?
here are my error messages logged to the console:

    [notice ] ofxTwitter::authorize: Authorizing app...
[notice ] ofxOAuth::loadCredentials: Unable to locate credentials file: ../../../data/credentials.xml
[ error ] ofxTwitter::updateHelpConfiguration: App not authorized.
0ERROR:  \266\310
[warning] ofxOAuth::obtainRequestToken: Return parameter did not have 2 values: <?xml version="1.0" encoding="UTF-8"?>
  <error>Desktop applications only support the oauth_callback value 'oob'</error>
 - skipping.
[warning] ofxOAuth::obtainRequestToken: Request token secret not returned.
[warning] ofxOAuth::obtainRequestToken: Request token not returned.
[ error ] ofxOAuth::update: Access failed.

i had a similar issue before see here but no remember well what was the reason (maybe the wrong keys or i missed to put some files in /data folder) do you create the app from scratch or are you testing the example?

indeed. the data folder is missing that credentials file. I’m trying to get the example to work…
and about the link: I’m checking the readme file now. at least the link says that the credentials file is created automatically after first authorization. I don’t get to that authorization is my problem…

Hi @suse_m Have yo specified a callback url on the Twitter side, any URL will work.

1 Like

yeah there was the error. reading the readme file usually makes sense! thanks a lot!

Hi @pelayo do you know if the addon still works? Im getting the same error like @suse_m

[notice ] ofxTwitter::authorize: Authorizing app...
[notice ] ofxOAuth::loadCredentials: Unable to locate credentials file: ../../../data/credentials.xml
ERROR: \200
[warning] ofxOAuth::obtainRequestToken: Return parameter did not have 2 values: <html>\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>\n<title>Error 401 Unauthorized</title>
<h2>HTTP ERROR: 401</h2>
<p>Problem accessing '/oauth/request_token?'. Reason:
<pre>    Unauthorized</pre>
 - skipping.

And i set an url in the twitter callback in the twitter side…