Assessment of emotion in a twitter or facebook feed is often called "sentiment analysis", because it involves analyzing the sentiments behind words in posts. In its simplest form, this involves having long lists of words that are generally accepted to convey a certain sentiment and assigning each post a score based on the words that it contains. This can be expanded on by giving other words scores based on the words that they are commonly seen with, and then using those words to score the sentiments being conveyed by a facebook or twitter feed as well. Obviously, that is a pretty rudimentary technique.
Sentiment analysis is generally considered to be a topic within the field of "Natural Language Processing," which is named for the fact that it involves getting computers to process "natural" (human) languages, as opposed to computer language.
There are a wide variety of tools that can be used to work on these problems. As PVD suggested, R is certainly a good one, and has a number of useful libraries. The tm (text mining) library is a good one. Python is also a good option, as it has a less steep learning curve and a very convenient twitter library (tweepy). There are also a lot of other python twitter libraries that I haven't tried out. For facebook I'm not sure what the best library is, but I think there are a bunch (pyFacebook, for one). All of these tools are open source.