Lesson 10: Consuming Web Services – Flickr and Google Maps

April 8th, 2010

This week, we launch into the exciting realm of popular web services (Facebook, Google, Delicious, Twitter, Flickr and many many more) out there.

Example #1 – Flickr API

We made used of the Flickr API and get public ‘geotagged’ photographs, and search and by the longitude and latitude position of the taken photograph.

The coordinates of the longitude and latitude of all places on earth can be ‘queried’ from sites like http://itouchmap.com/latlong.html.

To test the script, hop on to http://ricep.info/s4cep/rest/getFlickrPhotoLatLng.php and type in the latlong information of the starting and ending Position of the bounding box of the search area.

The script can be downloaded here. *Note that I have removed my Flickr API Key, to download and test your own app, you can get your own API key here*

Service Method used in this script:

flickr.photos.search

Example #2 – Mashup of Flickr API with Google API

The first example is well and good if my users are diligent and patient enough to search for the longitude and latitude information before using my site, but conventional wisdom tells us to be wary of making our audience work too hard. Thus, Google Map API will come a long way to ‘fill’ in the longitude and latitude information “automagically” when the user fills in the start and end address of the search boundary.

To test the script, hop on to http://ricep.info/s4cep/rest/getFlickrPhotoMinMax.php and type in the latlong information of the starting and ending address of the bounding box of the search area.

The script can be downloaded here. *Note that I have removed my Google API Key, to download and test your own app, you can get your own API key here*

Lesson 9: Project Requirements and Ajax

March 30th, 2010

Project Details:
Project Requirements

Ajax Scripts used today:
ajax_example

Reading:
A very good tutorial that explains AJAX concepts
http://bandwidthco.com/whitepapers/programming/js-ajax/Ajax%20Tutorial.pdf

Resources:
http://www.w3schools.com/PHP/php_ajax_database.asp
http://www.programmableweb.com
http://simplespark.com

Lesson 8 : Cookies and Sessions

March 23rd, 2010

Test Solution:

Test Answer

Scripts used today:

CookieSession

More FAQ reading for Cookies and Sessions

A collection of 23 tips on understanding and managing cookies in PHP

A collection of 19 tips on understanding and using sessions in PHP

Reading: Chapter on Cookies & Sessions

March 11th, 2010

Readings for the one-week break is as follows: Cookies & Sessions

Lesson 7: Validating using Regular Expression

March 2nd, 2010

A typical search and replace operation requires you to provide the exact text that matches the intended search result. Although this technique may be adequate for simple search and replace tasks in static text, it lacks flexibility and makes searching dynamic text at least difficult if not impossible.
With regular expressions, you can:

  • Test for a pattern within a string.For example, you can test an input string to see if a telephone number pattern or a credit card number pattern occurs within the string. This is called data validation.
  • Replace text.You can use a regular expression to identify specific text in a document and either remove it completely or replace it with other text.
  • Extract a substring from a string based upon a pattern match.You can find specific text within a document or input field.

Lecture Notes: Regular Expressions – notes
Homework: Error Checking and Form Feedback (due 7 Mar 2010)
NRIC Validator – supporting document for homework assignment
Scripts: Perl-Compatible Regular Expression(PCRE) scripts used in class

Lesson 6: Joining tables & PHP Connectivity

February 23rd, 2010

Last week, we saw how to improve database integrity via better database design through normalisation. After normalisation, our data has been “broken” up into smaller tables (so that data redundancy and the associate anomalies are removed). In order to “reconstruct” the data, we need to learn to use the JOIN table command in SQL. Also, we are now ready to dive into the mechanics of how we use PHP to ‘talk to’ your database and perform database activities.

Lecture Notes: Join Queries & PHP MySQL Connection
Supplementary Reading: PHP_MySQL_Notes
Zipped folder of scripts used today: scripts.zip
Assignment 5 (due 28 Feb 2010, 5pm):
- Example Film Rental Database, sakila,
Exercise-new - The context for the questions in this exercise is found in a really useful SQL Lesson Guide found http://mysql-tools.com/en/advanced-queries.html

Lesson 5: Database Design Concepts

February 9th, 2010

Today, we will look at the techniques of designing a database that is highly maintainable and easy to perform queries on. We will be “normalising” the data at hand, to ensure that duplication is minimized and data consistency is achieved when updates are performed.

Slides:  Normalisation Lecture Notes

Notes: A Tutorial by Fred Coulson

Assignment 4 (due 21 Feb 2010, 5pm):

Normalisation Exercise 1
Normalisation Exercise 2

Solutions:

Norm Exercise1 Solution

Norm Exercise2 Solution

Lesson 4: Common Web Development Tools

February 2nd, 2010

Today, as the NOI Selection Test is on, and several of your classmates are missing out on the lesson today, hence, I am pushing back the lesson on “Database Design Concepts” to next week.

So, meanwhile, we will learn a few tools that are commonly used in Web Applications:

1) Sending of Email
2) Date / Time Functions
3) Handling File Uploads
4) PHP and Javascript
5) Understanding HTTP Headers

A useful chapter is available from here.
Zipped source codes used today.

Lesson 3: Introduction to MySQL

January 26th, 2010

MySQL is a popular open-source database. Today, we will learn a bit more about it.

Notes:

SQL Command Summary
W3Schools

Assignment:

Assignment 3: Introduction to MySQL
Zipped file containing world.sql
Setup Instructions for World Database
Excel file of World Data

Lesson 2: Array and File Manipulation in PHP

January 19th, 2010

Scripts used today: scripts
Additional Notes: File Manipulation

Homework: Assignment 2, due 24 January, 5pm

Some thoughts for the day:
-  Are there inherent problems with using files to store customer’s orders?