Twitter page refresh via API

I use the Twitter API (via TweetSharp) and wondered if it is possible to automatically refresh the page from the API so that all users see the update? If so, is it possible to take another step forward if you only have a partial page refresh, so instead of the entire page, only the corresponding change is updated?

Thanks for any help

+7
c # refresh twitter partial-page-refresh
source share
3 answers

I think I understand your question that you want to display a bunch of users and their last tweet - but continue to check if their last tweet has changed and updated the screen when the user sends a tweet?

If so, the answer is that you need to call twitterapi asynchronously so often and pull out the last status (tweet) for each user - and if it's new, then use ajax to update part of the screen with the old status (tweet) in it.

In TweetSharp, if you have a Friends List, you can pull out your last tweet with something like:

string profileImageUrl = String.Empty; string name = String.Empty; string statusText = String.Empty; string createdAt = String.Empty; string screenName = String.Empty; foreach (TwitterUser friend in friends) { try { profileImageUrl = String.IsNullOrEmpty(friend.ProfileImageUrl) ? "" : friend.ProfileImageUrl; name = String.IsNullOrEmpty(friend.Name) ? "" : friend.Name; statusText = (friend.Status == null || friend.Status.Text.Length == 0) ? "unknown" : friend.Status.Text; //stops nullreferenceexception on instance createdAt = String.IsNullOrEmpty(friend.CreatedDate.ToString()) ? "" : friend.CreatedDate.ToString(); screenName = String.IsNullOrEmpty(friend.ScreenName) ? "" : friend.ScreenName; } catch (NullReferenceException) { profileImageUrl = ""; name = "unknown"; statusText = "unknown"; createdAt = ""; screenName = "unknown"; 

So, you can first display it on the screen.

Then use jquery (or javascript) to periodically hit the web service that reads the twitter api , and then use the data returned to update the last tweet if it changed.

Let me know if I have the wrong end of the stick.

EDIT:

An example of using Tweetsharp to post a new tweet on Twitter:

 var query = FluentTwitter.CreateRequest().AuthenticateAs(username,password).Statuses().Update("Posting status on StackOverflow").AsJson(); 
+1
source share

I do not use this DLL, but I write it, and the Twitter API expects you to call again - there is no update, as I know. If this dll allows you to query from the date, then this is possible and will probably be the parameter to call. I hope this helps a little

0
source share

If you are using ASP.NET, you can use AJAX with the UpdatePanel control . This is probably the easiest way to get what you need with ASP.NET.

0
source share

All Articles