Tech Friday: API Programming 101

I’ve working on an add-on application for the Shopify e-Commerce web service, that allows you to have a web store completely in the cloud. What we’re trying to do is to have the cart check-out function call a custom application which calculates shipping costs, because we have a slightly idiosyncratic way of dealing with those that isn’t accommodated by the standard Shopify functionality.

Shopify provides an API (Application Programming Interface) to their web site which allows developers to add extra functions to a customer’s web shop. Entry to the API is
provided in several different ways:

  • External Apps: Shopify calls an external function hosted at a publicly available web address. Presumably the same app provides functions for multiple customers and shops. There are bunch of these advertised on the Shopify web site. Some are free, some are supported by Shopify and some are built by third-party programmers, who make them available for $5.00 – $60.00 per month.  
  • Internal Apps: These are similar to internal apps, but are available for a single store. 
  • Embedded Apps: Haven’t quite figured this out yet, but my guess is that somehow this allows an app to be embedded in a single store, and hosted within the Shopify web server, thus obviating the need for a separate web server, and public web address.

I quickly wired up our shipping calculation in PHP. Its about 12 lines of code. The problem has been to try to find how to connect it to our Shopify check-out cart. Along the way, however, I’ve found some interesting tools.

It is a little ironic that some of the best PHP programming tools seem to exist primarly in Windows versions, but that most of the deployment of PHP happens on Linux/Apache web servers.  Ideas:

Notepad++   The favorite of my boss, but as I said to him, “its like writing with a stick in dirt”.  I use it all the time though for general editing of ASCII files.
JetBrains phpStorm I have the thirty-day trial for this, which also runs on the Mac. Looks promising.
CodeLobster for PHP Just found this free PHP editor which also has some support for javascript and CSS.

To create the publicly available web address that will host my app, I got an account with Heroku 

To examine calls to and from web services, I downloaded the the Firefox Plug-in HttpRequester.

To examine the web traffic, I use Fiddler.  To see web traffic in greater context (and to see all the data you’re sending to the NSA…)  I use WireShark.

All of the above are Windows applications. Other suggestions cheerfully accepted.  (For example, on the Mac, WiresShark uses an external Xquartz graphics library, which has to be launched separately. The whole thing seems a little flakey, but it works, all the same.)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s