Archive

Archive for August, 2019

TweetJS Display #Tweets on your website with #Javascript only

tweetjs

This is probably the start of a much larger project, but starting today, I launched TweetJS.com which is a browser-based Javascript library, that lets you display tweets on your website. No authentication needed.

Currently, it has two methods, ListTweetsOnUserTimeline and Search, where TweetJs.ListTweetsOnUserTimeline takes two parameters, the username, and a callback function. It will return data on tweets posted by a given user. and TweetJs.Search takes two parameters, the search query, and a callback function. It will return data on tweets that contain the search query.

They are called like this

TweetJs.ListTweetsOnUserTimeline("PetrucciMusic",
function (data) {
    console.log(data);
});

Under the hood, this makes an ajax call back to our server, which then makes the call to Twitter, using our authentication keys.

 

Categories: Uncategorized

Using #tweetmoasharp to retrieve tweets from a user’s timeline

logo_tweetmoasharp

Since Tweetsharp is no longer being maintained, there is a fork called tweetmoasharp that is actively maintained. It is pretty much a drop-in replacement for Tweetsharp, with minor differences.

Here’s some code that I wrote to retrieve the tweets from a given user’s timeline

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

var service = new TwitterService(_consumerKey, _consumerSecret);
service.AuthenticateWith(_accessToken, _accessTokenSecret);

var xt = service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions() { ScreenName = “PetrucciMusic” });
var strJson = service.Response.Response;

This returns tweets from the account https://twitter.com/PetrucciMusic

The TLS1.2 setting may not be needed, depending on what version of .NET you are using, but I was using an old version, which needed it.

 

Categories: Uncategorized