PHP: Expanding URLs using Google URL shortener API

Yesterday. google launched an API for its URL shortening service Using this API developers will be able to expand/shorten URLs and get a user’s analytics and history programmaticaly.

Below is a small snippet of PHP code that expands a short URL. The response comes in JSON format, so we will use the json_decode function to convert it to object.

Here is the full successfull response in JSON format.

Finally, note that Google recommends the use of an API key. You can visit this link to read more about key and get a key from this link.

After using the key, your URL will look like the following:

Favorite tech links of the week : 03 Jan – 09 Jan, 2011

This post contains some of the useful and interesting tech links I found during this week. To keep up to date with the latest information, subscribe to the feed or follow me on twitter @v08i

32 Javascript Alternatives with Pure CSS – Updated –


10 Google Chrome Extensions for a Faster Browser –

Chrome Extensions

75+ Tools for Visualizing your Data, CSS, Flash, jQuery, PHP –

75 Tools
Continue reading Favorite tech links of the week : 03 Jan – 09 Jan, 2011

PHP: Defining configuration values

Every web application requires configuration files which contain values that are used throughout the application. In this post we will look at some of the methods developers use to define configuration settings and also what should be avoided.

The ugly way

I have seen many many developers do this and am myself guilty of doing it during my initial coding days. Consider the following code.

Developers define 2 sets of same variables for each environment. First set is for development environment while second is for production. To switch the configuration developer must comment all other sets and uncomment the desired one. This is untidy and error prone. Never ever use this in your applications.

Continue reading PHP: Defining configuration values

A web developers rants for new year

2011Image Courtesy: Desizn Tech

2011 has begun and everyone on the web is either busy in making predictions for the web or taking resolutions for another year. This post reflects on plans that I have for this year. Personally, I don’t believe in resolutions that much. Adding to this fact that I am extremely lazy. So, absolutely no f****g guarentee for any of these to be complete. But it is always good to know where you are heading to. Here is what I plan to learn/achieve this year.

Write another book

Last year I got a chance to write a book on 2 of my favorite technologies : PHP and jQuery. The result was PHP jQuery Cookbook. Writing a book is an interesting and a great learning experience. You must know every word that you are writing because you cannot rollback once the words are out in print. Nevertheless, I would like to write one more book this year. Probably on Google APIs or various other APIs like facebook, twitter etc.

Read more blogs

I am an avid reader of web development blogs. Google reader and bookmarks toolbar are a great help. This year I will add more and more feeds so that I do not skip anything.

jQuery Mobile

Accept it. jQuery is a revolution. There are many great libraries like MooTools, PrototypeJS etc but jQuery is far ahead of them all. It has changed the way we write javascript. jQuery Mobile is another cross platform mobile framework for smartphones and tablets. With mobile apps increasing at a rapid rate, jQuery mobile is the coolest tool to learn.

Continue reading A web developers rants for new year

Searching text in a HTML table using jQuery

Filter Table

Here is the situation. You have a really long table with hundreds of rows and you want to filter the rows(instantly!) that contain a specific keyword in any of the table cells.

This article will show how this can be achieved with the help of jQuery.

View Demo Continue reading Searching text in a HTML table using jQuery