Another Way to Cache Phish.net API Results
Updated by Adam Scheinberg
The Phish.net API is an HTTP/javascript API. As such, it's incredibly easy to implement. While it's not as featureful as, say the API of Flickr, and it's not as powerful as the API of Google Maps, it's certainly simply enough to get integrated into your Wordpress blog in about 2 minutes.
The only problem with the current API (which is more a problem of javascript and the DOM than the actual API) is that it loads in the flow of the page at the speed of your connect. In short, if there is a lag in contacting Phish.net, the rest of your site may not continue to backfill the rest of the page until after the Phish.net part is loaded. I noticed this today while loading gadiel.com/phish, which implements the "getLatestSetlist" method of Phish.net. Since the API he's using it also using our hosted setlist callback, it paused until it was able to load.
The current Phish.net host shouldn't be slow very often, but it still can cause a slight delay, and although not anticipated, from time to time, may cause a noticeable lag. This also can occur if the path from the user's computer to phish.net is slow. It may be more noticeable on dial-up, a mobile connection, or a slow wifi connection. In that vein, I'd like to share an alternate way to implement the API.
First off, you'll need to host a PHP script. The script fetches the API from phish.net, which can't be done via javascript for security reasons. You must have this script on YOUR SERVER. Upload it and call it phishnet-api-helper.php (you can change the name, but you'll need to change it below as well). You can download phishnet-api-helper.php here.
Secondly, wherever you want your setlist to live, you'll want to enter this code in your page: <div id="pnetapi"></div>
You have just created a block into which we'll add the current setlist, when the DOM is ready. We do not need a callback function for this method, so you can remove any reference to the callback function. We also don't need to call the API directly, since this next bit will do it for us.
Then you'll want to choose one of the below "paths" depending on whether or not you use jQuery.
Obviously, if you put this PHP script into a folder called "scripts," you'd want to change the /phishnet-api-helper.php to /scripts/phishnet-api-helper.php.
Not only is that all you need, but it shouldn't disrupt the flow of the page loading.
If you're comfortable with code, you might want to check out the tutorial called "How to Cache the Phish.net API for Maximum Speed"
