Professional Twitter® Development With Examples in .NET 3.5

Book description

Twitter is rapidly moving up the social networking food chain and is currently outranked by only Facebook and MySpace. It features a programming API that allows you to build Web sites and applications (both desktop and mobile) for reading and posting to Twitter, finding other Twitter users, aggregating Twitter content, and other uses. This book walks you through the process of combining many programming tools in order to build exciting, useful, and profitable applications.

You'll begin with a look at RESTful services and examine how to structure your queries, handle asynchronous operations, use headers, and post binary data. From there, author and TweetSharp developer Daniel Crenna explains how to authenticate with the OAuth specification for Web and Windows applications.

  • Twitter is growing in popularity at a rapid pace and this book shows you how to take advantage of its programming API to build applications

  • Explains the various ways to design a Twitter application, including caching, third party application interoperability, real-time data binding, push vs. pull data scenarios, and more

  • Takes an in-depth look at TweetSharp, a .NET library for developing Twitter applications-whose creator is also the author of this book

  • Walks you through requesting and retrieving responses from Twitter's API

  • Warns you of considerations to take into account regarding authentication and security

Professional Twitter Development shows you how to get the most out of Twitter so that you can build your own applications for this exciting new platform.

Table of contents

  1. Copyright
  2. About the Author
  3. Credits
  4. Acknowledgments
  5. Introduction
    1. Who This Book Is For
    2. What This Book Covers
    3. How This Book Is Structured
    4. What You Need to Use This Book
      1. Setting Up Your Development Environment
        1. Using the Microsoft Web Platform Installer
        2. IIS 7.0 with ASP.NET Components
        3. ASP.NET MVC 1.0
        4. Microsoft® Silverlight™ 3 Tools Beta 1 for Visual Studio 2008 SP1
        5. SQL Server 2008 Express
        6. Visual Studio Web Developer Express and Above
        7. SDKs and Libraries
        8. Windows Azure Tools for Microsoft Visual Studio (Including the Azure SDK)
        9. TweetSharp v1.0
        10. Debugging HTTP Traffic
        11. Configuring Wireshark
    5. Summary
    6. Conventions
    7. Source Code
    8. Errata
    9. p2p.wrox.com
  6. 1. Working with RESTful Services
    1. 1.1. What is REST?
      1. 1.1.1. The REST Paradigm
        1. 1.1.1.1. REST Means Resources
        2. 1.1.1.2. REST Means Addressability
        3. 1.1.1.3. Example
        4. 1.1.1.4. REST Means Formats
        5. 1.1.1.5. REST Means Stateless
        6. 1.1.1.6. REST Means a Uniform Interface
    2. 1.2. HTTP and URIs
      1. 1.2.1. The Anatomy of a URI
        1. 1.2.1.1. Escaping and Encoding with Uri and HttpUtility
      2. 1.2.2. The Anatomy of HTTP Requests and Responses
        1. 1.2.2.1. Requests
        2. 1.2.2.2. Responses
      3. 1.2.3. Planning Features using HTTP Headers
      4. 1.2.4. Twitter and REST
    3. 1.3. Communicating with the Web and .NET
      1. 1.3.1. WebClient, HttpWebRequest and HttpWebResponse
        1. 1.3.1.1. Simplifying Web Communication with WebClient
        2. 1.3.1.2. Enhanced Control with HttpWebRequest and HttpWebResponse
        3. 1.3.1.3. Going Low Level with Sockets and TcpClient
        4. 1.3.1.4. Handling Exceptions
        5. 1.3.1.5. HTTP Basic Authentication
        6. 1.3.1.6. Username and Password
        7. 1.3.1.7. Realm
        8. 1.3.1.8. Working with Proxies, Gateways, and Firewalls
        9. 1.3.1.9. Twitter vs. .NET
        10. 1.3.1.10. Expect100Continue
        11. 1.3.1.11. Example
        12. 1.3.1.12. UseNagleAlgorithm
        13. 1.3.1.13. NetworkCredential and Pre-Authentication
      2. 1.3.2. Creating a Request Utility
        1. 1.3.2.1. URI Validation
        2. 1.3.2.2. Exception Handling
        3. 1.3.2.3. Basic Authorization
        4. 1.3.2.4. HTTP GET
        5. 1.3.2.5. HTTP POST
        6. 1.3.2.6. HTTP PUT
        7. 1.3.2.7. HTTP DELETE
    4. 1.4. Summary
  7. 2. The Twitter REST API
    1. 2.1. Obtaining a Twitter Account
    2. 2.2. Overview
      1. 2.2.1. Resources
        1. 2.2.1.1. Statuses
        2. 2.2.1.2. Users
        3. 2.2.1.3. Direct Messages
        4. 2.2.1.4. Friendships
        5. 2.2.1.5. Social Graph
        6. 2.2.1.6. Accounts
        7. 2.2.1.7. Favorites
        8. 2.2.1.8. Notifications
        9. 2.2.1.9. Blocks
        10. 2.2.1.10. Help
      2. 2.2.2. Representations
        1. 2.2.2.1. Formats
        2. 2.2.2.2. Elements
      3. 2.2.3. Authenticating Users
      4. 2.2.4. API Rate Limits
    3. 2.3. Twitter Features
      1. 2.3.1. Statuses
        1. 2.3.1.1. Public Timeline
        2. 2.3.1.2. Example
        3. 2.3.1.3. Friends Timeline [A] [R]
        4. 2.3.1.4. Example
        5. 2.3.1.5. User Timeline [A] [R]
        6. 2.3.1.6. Example
        7. 2.3.1.7. Show [A] [R]
        8. 2.3.1.8. Example
        9. 2.3.1.9. Update [A]
        10. 2.3.1.10. Example
        11. 2.3.1.11. Mentions [A] [R]
        12. 2.3.1.12. Example
        13. 2.3.1.13. Destroy [A] [R]
        14. 2.3.1.14. Example
      2. 2.3.2. Users
        1. 2.3.2.1. Friends [A] [R]
        2. 2.3.2.2. Example
        3. 2.3.2.3. Followers [A] [R]
        4. 2.3.2.4. Example
        5. 2.3.2.5. Show (A) [R]
        6. 2.3.2.6. Example
      3. 2.3.3. Direct Messages [A] [R]
        1. 2.3.3.1. Example
        2. 2.3.3.2. Sent [A][R]
        3. 2.3.3.3. Example
        4. 2.3.3.4. New [A]
        5. 2.3.3.5. Example
        6. 2.3.3.6. Destroy [A] [R]
        7. 2.3.3.7. Example
      4. 2.3.4. Friendships
        1. 2.3.4.1. Create [A]
        2. 2.3.4.2. Example
        3. 2.3.4.3. Destroy [A]
        4. 2.3.4.4. Example
        5. 2.3.4.5. Exists (A) [R]
        6. 2.3.4.6. Example
      5. 2.3.5. Social Graphing
        1. 2.3.5.1. Friends (A) [R]
        2. 2.3.5.2. Example
        3. 2.3.5.3. Followers (A) [R]
      6. 2.3.6. Account
        1. 2.3.6.1. Verify Credentials [A]
        2. 2.3.6.2. Example
        3. 2.3.6.3. End Session [A] [R]
        4. 2.3.6.4. Example
        5. 2.3.6.5. Update Delivery Device [A] [R]
        6. 2.3.6.6. Update Profile Colors [A] [R]
        7. 2.3.6.7. Example
        8. 2.3.6.8. Update Profile Image [A] [R]
        9. 2.3.6.9. Example
        10. 2.3.6.10. Update Profile Background Image [A] [R]
        11. 2.3.6.11. Example
        12. 2.3.6.12. Rate Limit Status (A)
        13. 2.3.6.13. Example
        14. 2.3.6.14. Update Profile [A] [R]
        15. 2.3.6.15. Example
      7. 2.3.7. Favorites
        1. 2.3.7.1. Data Representation: A collection of favorited status objects (20 at a time) Example
        2. 2.3.7.2. Create [A] [R]
        3. 2.3.7.3. Example
        4. 2.3.7.4. Destroy [A] [R]
        5. 2.3.7.5. Example
      8. 2.3.8. Notifications
        1. 2.3.8.1. Follow [A] [R]
        2. 2.3.8.2. Example
        3. 2.3.8.3. Leave [A] [R]
        4. 2.3.8.4. Example
      9. 2.3.9. Blocks
        1. 2.3.9.1. Create [A] [R]
        2. 2.3.9.2. Example
        3. 2.3.9.3. Exists [A] [R]
        4. 2.3.9.4. Example
        5. 2.3.9.5. Blocking [A] [R]
        6. 2.3.9.6. Example
        7. 2.3.9.7. Destroy [A] [R]
        8. 2.3.9.8. Example
      10. 2.3.10. Help
        1. 2.3.10.1. Test
        2. 2.3.10.2. Example
    4. 2.4. Twitter Objects
      1. 2.4.1. Statuses
        1. 2.4.1.1. Example
      2. 2.4.2. Users
        1. 2.4.2.1. Example
      3. 2.4.3. Direct Messages
        1. 2.4.3.1. Example
      4. 2.4.4. Rate Limit Status
        1. 2.4.4.1. Example
      5. 2.4.5. Errors
    5. 2.5. Working with the API
      1. 2.5.1. Twitter's DateTime Format
        1. 2.5.1.1. REST API
        2. 2.5.1.2. Search API
        3. 2.5.1.3. Rate Limit Status
      2. 2.5.2. Configuring a Custom Application Source
        1. 2.5.2.1. Source Parameter and User Agent
        2. 2.5.2.2. Optional Headers
      3. 2.5.3. Handling Errors
      4. 2.5.4. Requesting Data from Twitter
        1. 2.5.4.1. Web Requests on the Client Side
        2. 2.5.4.2. Example
    6. 2.6. Summary
  8. 3. Working with XML, JSON, and JSONP
    1. 3.1. Working with XML Responses
      1. 3.1.1. Using LINQ to XMLb
      2. 3.1.2. Using XML Attributes and XmlSerializer
    2. 3.2. Working with JSON Responses
      1. 3.2.1. Using ASP.NET AJAX's JavaScriptSerializer
      2. 3.2.2. Using WCF's DataContractJsonSerializer
    3. 3.3. Calling Back to Client Code with JSONP
      1. 3.3.1. Using Silverlight
      2. 3.3.2. Security Restrictions with JSONP
    4. 3.4. Summary
  9. 4. The Twitter Search API
    1. 4.1. Overview
      1. 4.1.1.
        1. 4.1.1.1. Search
        2. 4.1.1.2. Trends
        3. 4.1.1.3. API Rate Limits
        4. 4.1.1.4. Twitter Search's DateTime Format
    2. 4.2. Search Features
      1. 4.2.1.
        1. 4.2.1.1. Search
        2. 4.2.1.2. Example
        3. 4.2.1.3. Current Trends
        4. 4.2.1.4. Example
        5. 4.2.1.5. Daily Trends
        6. 4.2.1.6. Weekly Trends
        7. 4.2.1.7. Example
    3. 4.3. Search Operators
      1. 4.3.1. Boolean Logic
        1. 4.3.1.1. AND (implicit)
        2. 4.3.1.2. OR (explicit)
      2. 4.3.2. Exact Phrase
      3. 4.3.3. Exclusions
      4. 4.3.4. Hashtags
      5. 4.3.5. Referencing Users
        1. 4.3.5.1. From
        2. 4.3.5.2. To
        3. 4.3.5.3. References
        4. 4.3.5.4. User Sentiment
        5. 4.3.5.5. Positivity
        6. 4.3.5.6. Negativity
        7. 4.3.5.7. Question
      6. 4.3.6. Timelines
        1. 4.3.6.1. Since
        2. 4.3.6.2. Until
      7. 4.3.7. Context
        1. 4.3.7.1. Links
        2. 4.3.7.2. Source
    4. 4.4. Search Parameters
      1. 4.4.1.
        1. 4.4.1.1. Geo Location
        2. 4.4.1.2. Example
      2. 4.4.2. Pagination
      3. 4.4.3. Timelines
      4. 4.4.4. Callbacks
      5. 4.4.5. Globalization
    5. 4.5. Search Objects
      1. 4.5.1. Queries
        1. 4.5.1.1. Example
      2. 4.5.2. Trends
        1. 4.5.2.1. Examples
    6. 4.6. Converting Queries and Trends
    7. 4.7. Summary
  10. 5. Working with RSS and Atom Syndication
    1. 5.1. Syndication on the Web
    2. 5.2. Feed Objects
      1. 5.2.1. RSS 2.0
      2. 5.2.2. Atom 1.0
    3. 5.3. Consuming Feeds
      1. 5.3.1. Why Syndication?
      2. 5.3.2. With LINQ to XML
      3. 5.3.3. With SyndicationFeed and SyndicationItem
    4. 5.4. Synchronizing Applications with Feed Updates
    5. 5.5. Summary
  11. 6. Basic Authentication and OAuth
    1. 6.1. The Pitfalls of Basic Authentication
      1. 6.1.1. User Credentials are Visible
      2. 6.1.2. Credentials are Reusable
      3. 6.1.3. Credentials are One-Way
      4. 6.1.4. Existing Alternatives to Basic Authentication
        1. 6.1.4.1. HTTPS and SSL
        2. 6.1.4.2. Digest Authentication
    2. 6.2. What Is Data Portability?
    3. 6.3. What Is OAuth?
      1. 6.3.1. User Credentials are Hidden
      2. 6.3.2. Credentials are Not Reusable
      3. 6.3.3. Credentials are Two-Way
    4. 6.4. The OAuth Specification
      1. 6.4.1.
        1. 6.4.1.1. OAuth Consumers and Publishers
        2. 6.4.1.2. Encoding
        3. 6.4.1.3. Generating Timestamps
        4. 6.4.1.4. Generating Nonces
        5. 6.4.1.5. Generating Signatures
        6. 6.4.1.6. Sending OAuth Credentials
    5. 6.5. OAuth Workflow
      1. 6.5.1.
        1. 6.5.1.1. Retrieving an Unauthorized Request Token
        2. 6.5.1.2. Redirecting the User to the Provider Authorization Site
        3. 6.5.1.3. Exchanging a Request Token for an Authorized Access Token
        4. 6.5.1.4. Accessing a Protected Resource with an Access Token
    6. 6.6. Walkthroughs
      1. 6.6.1. Setting Up Your Twitter Application to Use OAuth
      2. 6.6.2. Authenticating an ASP.NET Web Application
      3. 6.6.3. Authenticating a Desktop, Console, or Mobile Application
        1. 6.6.3.1. Improving the User Authorization Experience for Desktop Applications
    7. 6.7. Summary
  12. 7. Maximizing Performance and Functionality
    1. 7.1. Caching
      1. 7.1.1. User Photos
      2. 7.1.2. Statuses and Users
    2. 7.2. Working with Twitter Constraints
      1. 7.2.1. Storing Authentication Values
      2. 7.2.2. Uploading Files with Multi-Part Form Posts
      3. 7.2.3. Rate Limiting in the Response
      4. 7.2.4. Designing Applications with Rate Limits
      5. 7.2.5. Retrieving Data for Popular Users
      6. 7.2.6. Filtering Data
      7. 7.2.7. Compressing Response Data
    3. 7.3. Extending Twitter with Third-Party Applications
      1. 7.3.1. Adding Photo Features with TwitPic, yFrog and Twitgoo
      2. 7.3.2. Stay on Top of Trends with TwitScoop
      3. 7.3.3. Twitter Application Directories
    4. 7.4. Unit Testing Twitter
      1. 7.4.1. Mocking RESTful Services
      2. 7.4.2. Generating Data
        1. 7.4.2.1. Mocking Text
    5. 7.5. Summary
  13. 8. Data Push vs. Pull
    1. 8.1. Pushing Data
      1. 8.1.1. Advantages
      2. 8.1.2. Disadvantages
      3. 8.1.3. Using WCF Duplex Services
        1. 8.1.3.1. Defining Contracts
        2. 8.1.3.2. Creating a Host and Factory
        3. 8.1.3.3. Configuring Services
        4. 8.1.3.4. Server Messaging
        5. 8.1.3.5. Client Consumption
      4. 8.1.4. Using Gnip
        1. 8.1.4.1. Gnip's .NET Convenience Library
        2. 8.1.4.2. Authenticating a Gnip Account
        3. 8.1.4.3. Setting Up Publisher Filters and Rules
        4. 8.1.4.4. Polling Activities
        5. 8.1.4.5. Pushing Activities
        6. 8.1.4.6. Using WebHttpBinding for REST Services
      5. 8.1.5. Using the Twitter Streaming API
        1. 8.1.5.1. Public Stream Methods
        2. 8.1.5.2. Example
        3. 8.1.5.3. User Stream Methods
        4. 8.1.5.4. Example
        5. 8.1.5.5. Running a Twitter Stream
    2. 8.2. Summary
  14. 9. Introduction to TweetSharp
    1. 9.1. Hello, TweetSharp!
      1. 9.1.1. What Is a Fluent Interface?
      2. 9.1.2. Core Feature Overview
        1. 9.1.2.1. .NET Framework Support
        2. 9.1.2.2. Custom Client Configuration
        3. 9.1.2.3. Representational Formats
        4. 9.1.2.4. Query Format
        5. 9.1.2.5. Pagination
        6. 9.1.2.6. Time Windows
        7. 9.1.2.7. Authentication
        8. 9.1.2.8. Operation Modes
        9. 9.1.2.9. Data Class Conversion
    2. 9.2. Hello, Twitter!
      1. 9.2.1. Fetching Timelines
        1. 9.2.1.1. Obtaining User Profiles
        2. 9.2.1.2. Posting Statuses
        3. 9.2.1.3. Working with Direct Messages
        4. 9.2.1.4. Working with Friends and Followers
        5. 9.2.1.5. Working with Searches and Trends
        6. 9.2.1.6. Authenticating with OAuth
    3. 9.3. Performance
      1. 9.3.1. Caching Queries
        1. 9.3.1.1. Compressing Requests
        2. 9.3.1.2. Asynchronous Operation
        3. 9.3.1.3. Timed Tasks
        4. 9.3.1.4. Rate Throttling
        5. 9.3.1.5. Working with Rate Limits
        6. 9.3.1.6. Handling Errors
    4. 9.4. Features
      1. 9.4.1. Relative Time
      2. 9.4.2. Shortening URLs
      3. 9.4.3. Posting Photos
      4. 9.4.4. Retweeting
      5. 9.4.5. Working with Proxies
    5. 9.5. Unit Testing
      1. 9.5.1. Defining Mock Responses
      2. 9.5.2. Using Data Generation
    6. 9.6. Summary
  15. 10. Building a Cross-Platform Twitter Application
    1. 10.1. The Application: Twiticism.com
      1. 10.1.1. Problem
      2. 10.1.2. Design
        1. 10.1.2.1. Why Windows Azure?
    2. 10.2. The Azure Cloud
      1. 10.2.1. Azure Storage Services
      2. 10.2.2. Azure Hosted Services
      3. 10.2.3. Creating an Azure Services Account
      4. 10.2.4. The Things You Need for Programming Against Azure
      5. 10.2.5. Shared Key Authentication
      6. 10.2.6. Designing Applications for the Cloud
        1. 10.2.6.1. Web Roles
        2. 10.2.6.2. Worker Roles
        3. 10.2.6.3. Blobs
        4. 10.2.6.4. Queues
        5. 10.2.6.5. Tables
        6. 10.2.6.6. Debugging
        7. 10.2.6.7. Logging
        8. 10.2.6.8. Creating a New Azure Application
        9. 10.2.6.9. Deploying and Promoting an Azure Application
      7. 10.2.7. Working with Azure Queues
        1. 10.2.7.1. Creating a Queue
        2. 10.2.7.2. Deleting a Queue
        3. 10.2.7.3. Listing All Queues on an Account
      8. 10.2.8. Working with Azure Tables
        1. 10.2.8.1. Creating a Table
        2. 10.2.8.2. Introducing StorageClient
        3. 10.2.8.3. Working with Table Entities
      9. 10.2.9. Hosting a Twitter Proxy in the Cloud
      10. 10.2.10. Running a Global User Cache in the Cloud
      11. 10.2.11. ASP.NET Membership in the Cloud
    3. 10.3. Silverlight Application Highlights
      1. 10.3.1. Building a Twitter Image Handler
      2. 10.3.2. Building a Twitter Search Poller
      3. 10.3.3. Going Cross-Platform
    4. 10.4. Summary

Product information

  • Title: Professional Twitter® Development With Examples in .NET 3.5
  • Author(s): Daniel Crenna
  • Release date: September 2009
  • Publisher(s): Wrox
  • ISBN: 9780470531327