Gelder Gelder - 1 year ago 128
JSON Question

TweetInvi Tweets to string or Json

I'm certainly not well experienced when it comes to c# but require it odd time SSIS, I'm trying to use TweetInvi to extract a timeline and then insert that time line data into a string file into a database to be processed. but I'm struggling...please help or point me in a direction of help.

here is what I've got

private void button1_Click(object sender, EventArgs e)
Auth.SetApplicationOnlyCredentials("XxxxxxxxXXXxxxXXX", "XXxxxXXX");


var usertimelinetweets = Timeline.GetUserTimeline("Testr",1);


Clearly at the most basic point, but I simple am in the dark here.

Answer Source

What you are trying to achieve is actually quite simple. Tweetinvi is automatically installed with Newtonsoft.Json.NET.

You can use Tweetinvi 1.0 support for serialization as followed :

var tweets = Timeline.GetHomeTimeline();

// Store 1 array
var json = JsonConvert.SerializeObject(tweets.Select(x => x.TweetDTO));

// Or iterate
foreach (var tweet in tweets)
    var tweetjson = JsonConvert.SerializeObject(tweet.TweetDTO);

You can learn more in the documentation:

Note that for some reason Timeline.GetUserTimeline requires User Authentication as noted in the documentation :

To do that use Auth.SetUserCredentials as opposed to Auth.SetApplicationOnlyCredentials.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download