Cover image for Twitter API: Up and Running

Book description

This groundbreaking book provides you with the skills and resources necessary to build web applications for Twitter. Perfect for new and casual programmers intrigued by the world of microblogging, Twitter API: Up and Running carefully explains how each part of Twitter's API works, with detailed examples that show you how to assemble those building blocks into practical and fun web applications. You'll also get a complete look at Twitter culture and learn how it has inspired programmers to build hundreds of tools and applications. With this book, you will:

  • Explore every component of a Twitter application and learn how the API responds

  • Get the PHP and MySQL code necessary to build your own applications, with explanations of how these ingredients work

  • Learn from real-world Twitter applications created just for this book

  • Discover the most interesting and useful Twitter programs--and get ideas for creating your own--with the book's Twitter application directory

Twitter offers a new way to connect with people on the Internet, and Twitter API: Up and Running takes you right to the heart of this technology.

"Twitter API: Up and Running is a friendly, accessible introduction to the Twitter API. Even beginning web developers can have a working Twitter project before they know it. Sit down with this for a weekend and you're on your way to Twitter API mastery." --Alex Payne, Twitter API Lead

"Twitter API: Up and Running is a very comprehensive and useful resource--any developer will feel the urge to code a Twitter-related application right after finishing the book!" --The Lollicode team, creators of Twitscoop

Table of Contents

  1. Special Upgrade Offer
  2. A Note Regarding Supplemental Files
  3. Preface
    1. Who This Book Is For
    2. How This Book Is Organized
    3. Conventions Used in This Book
    4. Using Code Examples
    5. Safari® Books Online
    6. We’d Like to Hear from You
    7. Acknowledgments
  4. 1. Hello Twitter
    1. What Are You Doing?
      1. Rules of Engagement
      2. Opportunistic Interruptions
      3. Twitter Is Like a Side-by-Side Conversation
    2. History of Twitter
      1. A Brief History of Microblogging
      2. Believe It or Not: Twitter Was Inspired by Bike Couriers
      3. Millions and Millions Served
      4. The Rise of the Fail Whale
      5. Who Wants to Be a Millionaire? Gauging Twitter’s Profitability
        1. Charging for service
        2. Self-selecting advertisers
        3. Implementing an open source service model
      6. Developers Are Users, Too
    3. Creative Uses of Twitter
      1. Twitter Utilitarianism
      2. Twitter for News
      3. Twitter for Science
      4. Twitter for God
      5. Twitter for Emergencies
      6. Twitter for Marketing
      7. Twitter for Social Change
      8. Twitter for Money
      9. Twitter for Games
      10. Twitter for Anthropomorphism
      11. Twitter for Help
      12. Twitter for Creativity
      13. Twitter for Education
      14. Twitter for Entertainment
      15. Twitter for Sports
      16. Twitter for Evil
      17. Twitter As a Shared Event
      18. Twitter for Everyone
    4. A Changing Culture
  5. 2. Twitter Applications
    1. Twitter’s Open API
    2. Finding Inspiration
    3. Tools for Publishing
      1. Twitterfeed
      2. SnapTweet
      3. SecretTweet
    4. Tools for the Information Stream
      1. Twittervision
      2. Twitter Matrix
      3. Twalala
    5. Tools of Appropriation
      1. Track This
      2. LiveTwitting
      3. FoodFeed
    6. Tools for Search
      1. TwitDir
      2. Green Tweets
      3. TweetBeep
      4. Tweet Scan
      5. Favrd
    7. Tools of Aggregation
      1. Twappi
      2. Twitscoop
      3. Twist
    8. Tools for Statistics
      1. What’s Your Tweet Worth?
      2. TweetStats
      3. Follow Cost
      4. Twitter Grader
      5. Twitterank
    9. Tools for the Follow Network
      1. Does Follow
      2. Qwitter
      3. Friend or Follow
      4. Mr. Tweet
      5. Omnee
      6. Twitree
    10. And Many More
  6. 3. Web Programming Basics
    1. XHTML
      1. Web Pages
        1. Form tags
      2. A Nod to Some Other XML Structures
    2. CSS
      1. Assigning Styles to Structure
      2. Laying Out Your Web Page Content
      3. Decorating the Web Page Content
      4. Getting the Browser to Recognize Styles
    3. PHP
      1. How to Accept Candy from Strangers
        1. SQL injection attacks
        2. CRLF injection attacks
        3. Cross-site request forgery (CSRF) attacks
      2. Strings, Arrays, and Objects
      3. Manipulating the Data You Collect
      4. Knowing Your Environment
      5. Controlling the Flow of Logic
        1. if…elseif…else
        2. while
        3. for
        4. foreach
        5. switch…case…break
        6. try…catch
        7. die() or exit()
      6. File Management
      7. Connecting to the Database
      8. Building a Custom Function
        1. Including more code in your application
        2. Defining your own function
      9. SimpleXML
      10. DOM
      11. cURL
      12. Debugging
    4. MySQL
      1. Creating a New Table
      2. Retrieving Information from the Database
      3. Changing Information in the Database
    5. A Place to Call /home
      1. Selecting a Host Server
      2. Automation
        1. Pseudoautomation hacks
    6. Further Reading
  7. 4. Meet the Twitter API
    1. Accessing the API
      1. HTTP Requests
        1. GET
        2. POST
        3. DELETE
      2. HTTP Status Codes
      3. Format
        1. RSS and Atom
      4. Authentication
      5. A Peak at OAuth
      6. Parameters
        1. Parameters that may be required
        2. Other parameters that may be useful
      7. Rate Limiting
        1. Checking the rate limit status
        2. Whitelisting
      8. Keeping Development Light
    2. Play Along at Home
    3. The API Methods
      1. Publishing
        1. Post a Tweet
        2. Delete a Tweet
      2. The Information Stream
        1. Show a Tweet
        2. View the Public Timeline
        3. View a Friends Timeline
        4. View an Individual Timeline
        5. View Replies
        6. View Favorites
        7. Create a Favorite
        8. Delete a Favorite
      3. The Follow Network
        1. Show Member Profile
        2. View Members Being Followed
        3. View Followers
        4. Get All Followers
        5. Get All Friends
        6. Follow a Member
        7. Unfollow a Member
        8. Confirm a Follow
        9. Block a Member
        10. Remove a Block
      4. Communication
        1. List Received Messages
        2. List Sent Messages
        3. Create a Message
        4. Delete a Message
        5. Show a Message
      5. Member Account
        1. Update Member Location
        2. Update Member Profile
        3. Update Profile Colors
        4. Update Background Image
        5. Update Profile Image
        6. Update the Delivery Device
        7. Turn On/Off Notification
      6. API Administration
        1. Test
        2. Verify Credentials
        3. Check Rate Limit Status
        4. End a Member Session
      7. Search
        1. Keyword Search
          1. Content searches
          2. Meta filters
          3. Operators
          4. Optional parameters
        2. Monitor Trends
    4. Other Data Options
    5. Gone Phishing: A Word About Passwords
      1. Is Twishing Worth the Effort?
        1. Controlling
        2. Invading
        3. Stealthing
        4. Screaming
        5. Damaging
        6. Annoying
        7. Deceiving
      2. OAuth Can Help
  8. 5. Meet the Output
    1. User Objects
      1. User Elements
    2. Status Objects
      1. Status Elements
    3. Message Objects
      1. Direct Message Elements
    4. Search Objects
      1. Feed Elements
      2. Entry Elements
    5. ID Objects
      1. ID Elements
    6. Response Objects
      1. Response Elements
    7. Hash Objects
      1. Hash Elements
      2. Errors
  9. 6. Application Setup
    1. Establishing Your Twitter Account
      1. Registering a New Twitter Member Account
      2. Configuring Your New Account
        1. Account tab
        2. Picture tab
        3. Other settings
    2. Creating Your Database
      1. Making Sure There Is a There There
      2. Giving the Database Some Structure
    3. Included Functions
      1. Creating Your Includes Directory
      2. Environment Functions
        1. getServerPath()
        2. getHTTPpath()
      3. API Configuration Functions
        1. prepAPI()
        2. prepRequest()
        3. apiRequest()
      4. Database Functions
        1. getDBconfiguration()
        2. openDB()
        3. closeDB()
      5. SQL Queries
        1. getQueries()
      6. Data Parsing Functions
        1. parseFeed()
        2. parseXML()
        3. createDOMfromURL()
        4. createParserFromString()
        5. createXMLshell()
        6. createRSSshell()
        7. formatTweetAsXHTML()
        8. addItem()
      7. Password Management Functions
        1. securePassword()
        2. comparePassword()
        3. scramblePassword()
        4. unscramblePassword()
      8. Data Validation Functions
        1. checkInput()
        2. isSubmitted()
        3. isValidTweet()
        4. hasCredentials()
        5. hasAccess()
      9. Data Sorting Functions
        1. sortData()
        2. compareFollowNet()
      10. Statistics Functions
        1. groupStats()
      11. Log Management Functions
        1. openFile()
        2. writeFile()
        3. closeFile()
        4. deleteFile()
      12. Status Messages
        1. getResponse()
      13. HTML Template Functions
        1. getHeader()
        2. getInterface()
        3. getFooter()
    4. CSS
  10. 7. Sample Applications
    1. Meet the Sample Apps
      1. Why Are You Asking for My Password?
    2. Administration Tool
      1. Take the App for a Spin
      2. Check Under the Hood
        1. Include external functions
        2. Initialize values
        3. Parse input
        4. Configure API requests
        5. Initiate cURL
        6. Prepare database interaction
        7. Validate access
        8. Save data
        9. Determine feedback response
        10. Clean up
        11. Render interface
      3. Shifting Gears
    3. Tweet Publisher
      1. Take the App for a Spin
      2. Check Under the Hood
        1. Parse input
        2. Post message
        3. Render interface
      3. Shifting Gears
    4. Auto Tweet
      1. Take the App for a Spin
      2. Check Under the Hood
        1. Parse input
        2. Disable profile
        3. Retrieve stored data
        4. Process deletion request
        5. Check feed
        6. Save profile
      3. Shifting Gears
    5. Tweet Broadcast
      1. Take the App for a Spin
      2. Check Under the Hood
        1. Retrieve stored data
        2. Process deletion request
        3. Compare groups
        4. Save group
        5. Render interface
      3. Shifting Gears
    6. Broadcast Feed
      1. Take the App for a Spin
      2. Check Under the Hood
        1. Parse input
        2. Retrieve update timestamp
        3. Initiate XML
        4. Add daily updates
        5. Render RSS feed
      3. Shifting Gears
    7. Tweet Alert
      1. Take the App for a Spin
      2. Check Under the Hood
        1. Confirm follower status
      3. Shifting Gears
    8. Network Viewer
      1. Take the App for a Spin
      2. Check Under the Hood
        1. Get user profile
        2. Get follow network
        3. Sort follow network
        4. Format follow network
        5. Render interface
      3. Shifting Gears
    9. Best of Twitter API
      1. Take the App for a Spin
      2. Check Under the Hood
        1. Parse input
        2. Add bookmarks
      3. Shifting Gears
  11. 8. Automated Tasks
    1. RSS to Tweet
      1. Check Under the Hood
        1. Include external functions
        2. Initiate logging
        3. Prepare database interaction
        4. Retrieve stored data
        5. Post message
        6. Clean up
        7. Log output
    2. Aggregate Broadcast
      1. Check Under the Hood
        1. Retrieve stored data
        2. Purge old stored data
        3. Log output
    3. Scan Tweets
      1. Check Under the Hood
        1. Retrieve master password
        2. Retrieve last ID
        3. Check for matching tweets
        4. Format message
        5. Retrieve users
        6. Confirm follower status
        7. Notify users
        8. Log activity
        9. Log output
    4. Queue Users
      1. Check Under the Hood
        1. Mine new users
    5. Collect Favorites
      1. Check Under the Hood
        1. Retrieve master password
        2. Retrieve queue
        3. Retrieve favorites
        4. Update queue
        5. Log output
  12. A. Twitter API Reference
    1. Status Methods
      1. Delete a Tweet
      2. View Followers
      3. View Members Being Followed
      4. View a Friends Timeline
      5. View the Public Timeline
      6. View Replies
      7. Show a Tweet
      8. Post a Tweet
      9. View an Individual Timeline
    2. Users Methods
      1. Show Member Profile
    3. Direct Message Methods
      1. List Received Messages
      2. Delete a Message
      3. Create a Message
      4. List Sent Messages
    4. Friendship Methods
      1. Follow a Member
      2. Unfollow a Member
      3. Confirm a Follow
    5. Social Graph Methods
      1. Get All Friends
      2. Get All Followers
    6. Account Methods
      1. End a Member Session
      2. Check Rate Limit Status
      3. Update the Delivery Device
      4. Update Member Location
      5. Update Member Profile
      6. Update Background Image
      7. Update Profile Colors
      8. Update Profile Image
      9. Verify Credentials
    7. Favorite Methods
      1. View Favorites
      2. Create a Favorite
      3. Delete a Favorite
    8. Notification Methods
      1. Turn On Notification
      2. Turn Off Notification
    9. Block Methods
      1. Block a Member
      2. Remove a Block
    10. Help Methods
      1. Test
    11. Search Methods
      1. Keyword Search
      2. Monitor Trends
  13. Index
  14. About the Author
  15. Colophon
  16. Special Upgrade Offer
  17. Copyright