Chapter 5. Meet the Output

image with no caption

kmakice You give and give and give. Let Twitter return the favor.

In the previous chapter, we looked at all the wonderful ways you can send commands to the Twitter API. Now, what are those commands going to do for you? For starters, Twitter will give you lots of useful data. In this chapter, we’ll take a closer look at the stuff Twitter sends back to you in answer to your requests for data.

The Twitter API supports different formats (.xml, .json, .rss, and .atom), but for this book I will use the custom XML format provided by Twitter (.xml). You could use .json instead, and it would work just as well. One format isn’t appreciably better than the other; they’re just different. It’s a matter of personal choice, and I chose XML.

Note

One exception is with applications using the Search method. The search API returns results using Atom, a particular variation of XML.

XML uses semantic tags to wrap up the data in a way that is easy to extract. The format is useful in separating the data layer from the presentation layer, so the same information can be rendered on a computer or cell phone screen in whatever way works best for that device.

Note

Unless you are specifically looking for the data returned by Twitter, it is better practice to look at the HTTP status code returned from the request. A code of 200 always indicates success. Response objects can and will change, ...

Get Twitter API: Up and Running now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.