With the advent of the term Web 2.0, web services have become popular, providing some functions for the exchange of information between different sites and servers. Now it is possible to post data in several sources at once, read them and, possibly, send them again.
In this connection, I think, at all on hearing, such technologies as XML-RPC, SOAP and, probably, REST? Not? Have not heard about REST (Representational State Transfer)? In order to clarify a bit in your head, you can read the article “
REST as an alternative to SOAP ” about the technology itself or watch a video about the
implementation of interaction in Ruby .
I will give a small, but very significant example of interaction with
del.icio.us in PHP.
')
The object of the experiment will be the beloved del.icio.us, and the goal will determine the receipt of our bookmarks on some tag for placement on your website. Immediately, I’ll warn you that openssl is required for the example to work, because the work is done using secure https. In Denver, this is done by uncommenting a single line in php.ini and copying php_openssl.dll to the ext folder.
We all know that the SimpleXML extension is implemented in PHP5, which we can easily use in the example to parse the response from the server.
$u = 'username';
$p = 'password';
$uri = "https://{$u}:{$p}@api.del.icio.us/v1/posts/all?tag=php";
$bookmarks = new SimpleXMLElement($uri, NULL, true);
foreach ($bookmarks->post as $bookmark)
{
echo '';
echo htmlentities($bookmark['description']);
echo "
\n";
}
Explaining each line does not make sense, because they have long been familiar to any PHP programmer.
Have a good use!