View Full Version : Understanding web services

01-04-2006, 07:29 PM
Hello everyone..

I have a couple of queries regarding the webservices.

I have used the Yahoo! Maps and the Google Maps API. Though neither of really require any server side scripting, Yahoo! offers a REST based service where if you send a URL with an address in it, and you get back an XML file containing detail about the zip code. The XML could then be parsed using something like the SimpleXML module of php. I simply used fopen to open the URL and sent the contents of the opened file into another file and that file had the XML details returned.

However, what I want to learn is how to establish connectivity with a server and send stuff. Here is a typical example

It says to post a blog, send the following:
To create a new entry:

POST /atom/3187374 HTTP/1.1
Content-type: application/xml
Host: www.blogger.com
Authorization: BASIC c3RldmVqOm5vdGFyZWFscGFzc3dvcmQ=

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<entry xmlns="http://purl.org/atom/ns#">
<title mode="escaped" type="text/plain">atom test</title>
<generator url="http://www.yoursitesurlhere.com">Your client's name here.</generator>
<content type="application/xhtml+xml">
<div xmlns="http://www.w3.org/1999/xhtml">Testing the Atom API</div>

Can the above be done using PHP? What module do we need? A big question of mine, what is the long complicated string that comes after the BASIC part in the Authorization section?

Even the del.icio.us API is somewhat similar, and requires HTTP-Auth. Now what is that? How do I send that through PHP?

In other words, is this in anyway following the ideas of REST? How do I send this "file" (assuming I am write the entire data into a file)? Next, how do I "send" it to the server?

By the way, is this what is XML-RPC?

Any help with this, please?

01-04-2006, 10:13 PM
Best way to go is to use cURL (http://www.php.net/manual/en/ref.curl.php) to send and recieve GET or POST requests to other servers