SOLVED: ofxTwitter Status::fullText() – no string return

Hi there!
I’m currently building an app which streams tweets based on specific hashtags, majorly on the ofxTwitter add-on. As the Status::text() function doesn’t show the whole extent of long tweets (at least not in my case), I was trying to use the fullText() function instead. However, I can’t seem to be able to retrieve any tweet with it:

void ofApp::onStatus(const ofxTwitter::Status& status)

{

count++;

ofLogNotice("ofApp::onStatus") << "Text: " << status.fullText();

ofLogNotice("ofApp::onStatus") << "\tCoordinates: " << (status.coordinates() ? ofToString(status.coordinates()) : "NONE");

ofLogNotice("ofApp::onStatus") << "\tPlace: " << (status.place() ? ofToString(status.place()->fullName()) : "NONE");

}

06

I’m probably missing something, so any help would be highly appreciated!
(Sorry if it’s not the best description as I’m still an openFrameworks beginner.)

Cheers!

Hey, I’m getting the same issue. There the full-text field exists on messages greater than ~140 chars, but the field (and other fields) aren’t being copied correctly. It is parsing in the original JSON, though. Anyway, I’m looking into it and will post here if / when I get it figured out.

Wait, I figured it out.

So, back in 2017, Twitter introduced the concept of “Extended Tweets”. You can read more about it here. Since the ofxTwitter::Status object follows the json very closely, you currently have to do a little bit more work to get access to the extended Status data. FWIW, after having investigated this at length, I’m considering making this a bit more intuitive (i.e. for those fields that are “Extended tweet” fields, the returned values on a base tweet would point to the extended tweet data if it is available). Until then, you can access the full tweet like this if status.text() is truncated:

if (status.extendedTweet() != nullptr)
{
        ofLogNotice("ofApp::onStatus") << "Full Text: " << status.extendedTweet()->fullText();
}

Alternatively if the text is truncated, you can query status.truncated(), but this essentially does the same as asking status.extendedTweet() != nullptr, though truncated is a field in the transmitted json and checking for a nullptr is not. Anyway … hope that helps!

1 Like

Heya,
Ah, I see…
Thanks so much for your quick explanation and the code, it works perfectly now! Again, many many thanks for your effort!
Cheers!

1 Like