Sjoerd Maessen blog

PHP and webdevelopment

Archive for the ‘API’ Category

PHP hook, building hooks in your application

with 6 comments

Introduction
One of the real challenges in building any type of framework, core or application is making it possible for the developers to hook into the business logic at specific points. Since PHP is not event based, nor it works with interrupts you have to come up an alternative.

The test case
Lets assume we are the main developers of a webshop framework. Programmers can use our framework to build complete webshops. Programmers can manage the orders that are placed on the webshop with the order class. The order class is part of our framework and we don’t want it to be extended by any programmer. However we don’t want to limit to programmers in their possibilities to hook into the orders process. Read the rest of this entry »

Written by Sjoerd Maessen

May 23rd, 2011 at 8:02 pm

Posted in API

Tagged with , , ,

ImageMagick installing and exploring it, a good alternative for the GD library

without comments

Although PHP GD library handles basic image operations quite good, you have probably run into the limitations of GD library as well, it is often slow, memory intensive and a bit complicated to use for advanced image effects. ImageMagick however is a very good alternative. It is an opensource software suite licensed under a BSD style license from IM itself. ImageMagick provides in all functionality that can be accomplished with the GD library but even goes a step further with support for more advanced image edit techniques. An example of such a technique is the recently added “liquid scaling” feature, this is a content aware scaling option. Read the rest of this entry »

Written by Sjoerd Maessen

July 19th, 2010 at 7:20 am

Posted in API,Server

Tagged with ,

Using the Google currency converter

without comments

For a project I’m working, I needed to get shipping rates from the UPS API (a blog post about this will follow soon).

The problem I ran into was that the UPS API returns the shipping rates with the currency of the country where the rates for are asked, so you can’t force it to always return the rates in EUR.

One solution to convert the prices is to make a very big array with all currency rates in it. I then would maintain the array every day at 9’o clock to check if the rates weren’t changed. Right, that’s not an option.
Read the rest of this entry »

Written by Sjoerd Maessen

January 11th, 2010 at 8:56 pm

Posted in API

Tagged with ,

Using the BitLy API to shorten urls

without comments

I was asked to place Twitter messages with product links when new products were added to a webshop. I’ve used my own Twitter class for posting the first test Tweet then I went looking for a shorten url a service to shorten the product links.

There are many url shorten services available on the internet, one of these services is Bitly.
The reasons why I’ve chosen Bitly:
– Urls don’t expire after a period of time.
– Bitly provides a click url summary (although Google Analytics can be used for this instead)
– Urls are short in length so i could use the remaining Tweet length for a small product description.
– And more important, they provide an easy to use API.
– Authentication does not require a password, we can use our API key instead.
Read the rest of this entry »

Written by Sjoerd Maessen

December 4th, 2009 at 5:05 pm

Posted in API

Tagged with ,