Burba100
Burba100

Reputation: 21

Get full tweet from node twitter

I need to get full tweets from users and I'm using node twitter package. But it gives me only portion of the tweet.

eg:-

text: 'I kind of hate how with most web development/new frameworks etc., I start out with the intention “I’d like to spend… (~link to tweet~)', truncated: true,

Basically I need to turn off the truncation. Is it possible with this package or any other way to do this?

const express = require('express');
const Twitter = require('twitter');
const config  = require('./twitter');


var twitter = new Twitter(config); // initialize twitter

twitter.get('/statuses/user_timeline.json?screen_name=donttrythis&count=2', function(error,tweets,response){
    if(error){
        console.log(error);
    }else{
        console.log(tweets);
    }
})

I tried tweet_mode=extended also but not working.

Upvotes: 0

Views: 995

Answers (1)

JeffProd
JeffProd

Reputation: 3148

If the tweet is a RT, you get the full text is in retweeted_status.

var params = {screen_name: 'donttrythis', count: 10, tweet_mode: 'extended'};

twitter.get('statuses/user_timeline', params, function(error, tweets, response) {
    if(error){
        console.log(error);
        return;
        }
    tweets.forEach(tweet => {
        if(tweet.retweeted_status) {tweet = tweet.retweeted_status;}
        console.log(tweet.full_text.trim());            
        });
    });

Upvotes: 2

Related Questions