Introduction xxi
Chapter 1 Working with Restful Services 1
What is Rest? 1
The Rest Paradigm 3
Http and Uris 6
The Anatomy of a Uri 7
The Anatomy of HTTP Requests and Responses 13
Planning Features using HTTP Headers 20
Twitter and Rest 21
Communicating with the Web and .Net 22
Webclient, HttpWebRequest and HttpWebResponse 22
Creating a Request Utility 41
Summary 53
Chapter 2 The Twitter Rest API 55
Obtaining a Twitter Account 55
Overview 56
Resources 57
Representations 58
Authenticating Users 60
API Rate Limits 60
Twitter Features 61
Statuses 61
Users 67
Direct Messages 70
Friendships 72
Social Graphing 73
Account 74
Favorites 79
Notifications 80
Blocks 81
Help 83
Twitter Objects 83
Statuses 84
Users 86
Direct Messages 89
Rate Limit Status 91
Errors 91
Working with the API 92
Twitter's DateTime Format 92
Configuring a Custom Application Source 93
Handling Errors 95
Requesting Data from Twitter 96
Summary 98
Chapter 3 Working with Xml, Json, and Jsonp 99
Working with Xml Responses 99
Using Linq to Xml 100
Using Xml Attributes and XmlSerializer 106
Working with Json Responses 110
Using Asp.Net Ajax's JavaScriptSerializer 110
Using Wct's DataContractJsonSerializer 123
Calling Back to Client Code with Jsonp 126
Using Silverlight 127
Security Restrictions with Jsonp 133
Summary 135
Chapter 4 The Twitter Search Api 137
Overview 137
Search Features 138
Search Operators 140
Boolean Logic 140
Exact Phrase 141
Exclusions 141
Hashtags 141
Referencing Users 141
Timelines 142
Context 143
Search Parameters 143
Pagination 144
Timelines 144
Callbacks 144
Globalization144
Search Objects 144
Queries 144
Trends 148
Converting Queries and Trends 150
Summary 156
Chapter 5 Working with Rss and Atom Syndication 157
Syndication on the Web 157
Feed Objects 158
Rss 2.0 158
Atom 1.0 160
Consuming Feeds 162
Why Syndication? 162
With Linq to Xml 163
With &Sgrave;yndicationFeed and SyndicationItem 168
Synchronizing Applications with Feed Updates 171
Summary 177
Chapter 6 Basic Authentication and OAuth 179
The Pitfalls of Basic Authentication 179
User Credentials are Visible 179
Credentials are Reusable 180
Credentials are One-Way 180
Existing Alternatives to Basic Authentication 180
What Is Data Portability? 181
What Is OAuth 182
User Credentials are Hidden 183
Credentials are Not Reusable 183
Credentials are Two-Way 183
The OAuth Specification 183
OAuth Workflow 191
Walkthroughs 203
Setting Up Your Twitter Application to Use OAuth 203
Authenticating an ASP.NET Web Application 205
Authenticating a Desktop, Console, or Mobile Application 208
Summary 211
Chapter 7 Maximizing Performance and Functionality 213
Caching 213
User Photos 214
Statuses and Users 221
Working with Twitter Constraints 230
Storing Authentication Values 230
Uploading Files with Multi-Part Form Posts 237
Rate Limiting in the Response 239
Designing Applications with Rate Limits 241
Retrieving Data for Popular Users 247
Filtering Data 252
Compressing Response Data 253
Extending Twitter with Third-Party Applications 256
Adding Photo Features with TwitPic, yFrog and Twitgoo 257
Stay on Top of Trends with TwitScoop 259
Twitter Application Directories 261
Unit Testing Twitter 262
Mocking Restful Services 262
Generating Data 265
Summary 270
Chapter 8 Data Push vs. Pull 273
Pushing Data 273
Advantages 273
Disadvantages 274
Using WCF Duplex Services 274
Using Gnip 289
Using the Twitter Streaming API 300
Summary 303
Chapter 9 Introduction to TweetSharp 305
Hello, TweetSharp! 305
What Is a Fluent Interface? 306
Core Feature Overview 306
Hello, Twitter! 312
Fetching Timelines 312
Performance 324
Caching Queries 324
Features 331
Unit Testing 335
Summary 337
Chapter 10 Building a Cross-Platform Twitter Application 339
The Application: Twiticism.Com 339
Problem 340
Design 340
The Azure Cloud 341
Shared Key Authentication 346
Designing Applications for the Cloud 348
Working with Azure Queues 355
Working with Azure Tables 360
Hosting a Twitter Proxy in the Cloud 371
Running a Global User Cache in the Cloud 377
Asp.Net Membership in the Cloud 383
Silverlight Application Highlights 388
Building a Twitter Image Handler 388
Building a Twitter Search Poller 392
Going Cross-Platform 398
Summary 400
Index 401