Getting into Real-Time APIs

You have many ways of accessing data in real time. The technologies have evolved a lot over the years to make this a simpler operation.

In the earlier days of the Web, the way you retrieved data quickly was to constantly “poll” data that you needed from sites. This involved a simple cron job (scheduling software for Linux and Unix-based systems) or similar scheduler to regularly run the script (or a regular loop that sleeps every so often), and the script constantly called a URL to get the information it needed. This process is similar to you calling https://graph.facebook.com/dummiesbook regularly to see whether you find any new information about the Facebook Page.

This approach had pros and cons. The few pros were as follows:

  • It was simple to write. You write the script as though It's going to be run once, and simply schedule it to run regularly and you're done. You had no other methods to call to subscribe to another service, no Web servers to run, and so on.
  • You could run the script fewer times, resulting in batch processing of data. This could be a pro or con depending on your viewpoint, but it allows you to process lots of data at a time, which may give your script a greater bird's-eye view of what's going on. Technically, assuming that you always have data, this could also mean slightly lower bandwidth costs.

However, the old way had many cons, listed as follows:

  • It was costly to your servers. Having to constantly repoll when most of those ...

Get Facebook® Application Development For Dummies® 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.