File_get_contents lead time if too long

A few things you can improve on.

  • Get all of them using a single request: https://api.twitch.tv/kraken/streams?channel=channel1,channel2,and,so,on
  • Load the page first and make the API call on the client-side, allowing you to show a friendly loading icon or something else.
  • Use cURL instead of file_get_contents. file_get_contents won’t allow you to handle errors or send the Client ID well at all.