Nov
28
2008
1

REST

Define: Rest

Representational state transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. It is not strictly a method for building what are sometimes called “web services.”
The terms “representational state transfer” and “REST” were introduced in 2000 in the doctoral dissertation of Roy Fielding, a principal authors of the Hypertext Transfer Protocol (HTTP) specification. The terms have since come into widespread use in the networking community.

REST strictly refers to a collection of network architecture principles which outline how resources are defined and addressed.
The term is often used in a looser sense to describe any simple interface which transmits domain-specific data over HTTP without an additional messaging layer such as SOAP or session tracking via HTTP cookies. These two meanings can conflict as well as overlap.

Systems such as PHP5 which follow Fielding’s REST principles are often referred to as “RESTful”. Systems that USE REST Feeds are reffered to RESTafarians.

Rest in PHP

REST, is a Web service architectural style in which the focus is on the presence of resources in the system.Each resource must be identified by a global identifier—a URI. To access these resources, clients communicate with the REST service by HTTP, and the server responds with a representation of the resource. This representation is often in the form of HTML or XML.

In simple words, Rest is a way of sending a query to a server. This query can include informatiom such as API Key, User name and Password for secure identification, or a query term such as search=$term to search the website for $terms. The results are returned in either HTML or more prefered XML.

REST needs API

All REST services need an API to allow developers to code the use of a RESTafarian website. This is because REST does not provide a WSDL or hany any common interface for communication.

Working with REST

Most REST requests are responded with XML data this means PHP can use SimpleXML or DOM. In this example we will be using SimpleXML because its more simpler to explain.

In this example we will use delicious.com, which is a bookmark website where you and others bookmark websites with tags to find them later. We can query delicious and ask them for all bookmarks related to the word Zend. Delicious will then respond to us all the websites it has been tagged with Zend:

$u = ’username’;
$p = ’password’;
$query = 'ZEND';
$fooTag = "https://{$u}:{$p}@api.del.icio.us/v1/posts/all?tag={$query}";
$bookmarks = new SimpleXMLElement($fooTag, NULL, true);
foreach ($bookmarks->post as $bookmark){
	echo<a href="’ . htmlentities($bookmark[’href’]) . ’">’;
	echo htmlentities($bookmark[’description’]);
	echo "</a><br />\n";
}

$footag s the resource identifier, for the data to be retrieved.
SimpleXML handles the request and the data received, then we use the SimpleXML object and foreach to output the matching bookmarks.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • Live
  • StumbleUpon
  • Technorati
  • TwitThis
Written by Adam in: Zend Classification General |
Nov
26
2008
0

XML Dom: Modifying Documents

PHP5 Dom allows you to add new data to a loaded document, this is done by useng
DomDocument::createElement();
DomDocument::createElementNS();
DomDocument::createTextNode();
Lets get down to Modifying XML Documents, this is one of the things i need to learn for the Zend PHP5 Certification never used DOM before.

In the example bellow we will add a new book to the libary.xml document:

$dom = new DomDocument(); //Create new DOM Object $dom-&gt;load(">createElement("book"); //Create a new "book" element
$book-&gt;setAttribute("meta:isbn", "0973589825"); //Add meta ISBN number to the book element
//----------
$title = $dom-&gt;createElement("title"); //Create a new element called title
$text = $dom-&gt;createTextNode("php|architect’s Guide to PHP Design Patterns"); //Set out the Books Title
$title-&gt;appendChild($text); //Attach the defined book title, to the new title element
$book-&gt;appendChild($title); //Attach the new title element(now with a value) to the Book element created earlyer.
//----------
$author = $dom-&gt;createElement("author","Jason E. Sweat"); //Create new author element
$book-&gt;appendChild($author); //Attach new author element to the book element
//----------
$publisher = $dom-&gt;createElement("pub:publisher", "Marco Tabini &amp; Associates
, Inc."); //Create a new publsher element
$book-&gt;appendChild($publisher); //Attach new publisher element to the book element
//----------
$dom-&gt;documentElement-&gt;appendChild($book);//Finaly the whole new book element with title, author and publisher needs attaching to the XML Dom object.

Follow the comments for basic analysis on what we did.
As you can see, in this example we start by creating a book element and set its meta:isbn attribute with DomElement::setAttribute().
Next, we create a title element and a text node containing the book title, which is assigned to the title element using DomElement::appendChild().
For the author and pub:publisher elements, we again use DomDocument::createElement(), passing the node’s text contents as the second attribute.
Finally, we append the entire structure to the DomDocument::documentElement property, which represents the root XML node;

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • Live
  • StumbleUpon
  • Technorati
  • TwitThis
Written by Adam in: Zend Classification General |
Oct
02
2008
4

Zend Certification Links, Links and Blogs

I admit it, Im great at useing google! I have read soo much about the Zend PHP 5 Certification today! So Can You!

Bellow you will find many links ranging from Official Links to Blog Posts and even some potentially illegal links to the Zend PHP5 Study Guide and Test Book.
(more…)

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • Live
  • StumbleUpon
  • Technorati
  • TwitThis
Sep
26
2008
0

About the “Zend PHP 5 Certification Study Guide” and Test Book

Zend PHP 5 Certification Study Guide 

Zend PHP 5 Certification Study Guide

This first blog post will concentrate on the Study Guide not so much the Test Book, both are recommended for test preparation.

The Study Guide prices range from $22 to $500, so Amazon’s $29.69 was reasonable considering on book it says MSRP $33. (It is written by Davey Shafik and Ben Ramsey.)
(more…)

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • Live
  • StumbleUpon
  • Technorati
  • TwitThis

WordPress Powered, Theme by TheBuckmaker.com | Add to Technorati Favorites. | RSS and Comments RSS