So Google have a SOAP API. This was just the excuse I needed to start playing with SOAP in PHP. And thus the game began.

First I had to choose a SOAP implementation. It turns out that php-PEAR has one that seems to be based on the well respected SOAPX4 I also wanted to start experimenting with some other libraries in PEAR and the code has a sort of quasi-stamp of approval from PHP as it's now in the main distributions. But for some reason PEAR wasn't installed on my hosting machine probably because I did it.

So the next stage is to update PHP from 1.0 to 1.2 and thereby hangs a tale. Now I host with Interland with their cheapest hosting package that gives me more or less full control. I get a virtual root in a sandbox but can access httpd.conf and such like. Interland told me that I couldn't update php because I needed full su root access. Hah! What do they know? Download php, untar it, work out what config parameters I need from phpinfo(), run ./configure etc, run make, run make install and let it fail. Sure enough, there is libphp4.so in the libs directory. Copy it to my own lib directory and then adjust httpd.conf so that the LoadModule php4_module line points at my copy instead of libexec. Restart apache and Bingo! php 4.12.

So now the next stage is to work out what happened to PEAR. It ought to go into /usr/libs but I don't have write access there. But I can see all the PEAR libraries in the php source tree. If I put it in usr/local/dah/dah/dah/libs then maybe I can get php to find it. Sure enough the php.ini file needs an entry include_path = ".:/usr/local/dah/dah/dah/lib/php/pear" Restart apache, run a short web page test for the pear DB library and it works. Bingo 2!

Now of course, so far I've glossed over several hours of trial and error and inspired guesswork, but the plan is coming together.

So now for SOAP. PEAR SOAP isn't in the php distribution but a quick Google search does turn up some minimal documentation and evidence of it being in the PEAR CVS. There's supposed to be a PEAR package manager that makes getting a new package easy. This is the point where you hit a web page on CVS PEAR install that says "This page not written yet". So finally I find the installed pear.in script that has to be moved and renamed pear and the instruction that says you need php to run it. Oh well, back to step 2 while I build a stand alone copy of php. Ok so I can see the executable. It's got execute rights. I type php, hit enter and get command not found. huh? It's right there. It takes me several minutes to realize that in Unix that should be ./php (stop laughing at the back) Makes complete sense. I have to tell it to run this php right here, not any old php it might find in the path.

So now php works, I can change the #! line at the top of the pear script to my copy, run ./pear So. list-available looks like a good option. Bang! xmlrpc support not loaded, error, error, error. ok, so we'll come back to that.

Then I remembered a note on a page about accessing Google API from php. "To use this code you will need both PEAR and the PEAR SOAP package installed somewhere on your php include path. You can get the SOAP package from CVS:" Have we got CVS? Yes. Type in the suggested lines. Bang! Some stupid CVS error that I can't be bothered to debug. OK. type the same lines into WinCVS locally. It all works, there's SOAP/, ftp it into the server's PEAR tree, fire up the sample php file, BINGO! Google search results! Try another search, Bang! No results. Ah-Hah! So when the note in the top of the example file said some returns don't work due to a bug in PEAR/SOAP parser it meant it.

So the next day, I have another look and the file now says "The PEAR SOAP package bug which caused some search terms to fail has now been fixed." So WinCVS, update, ftp, try again and Bingo!

So now I've got Google search results coming out of php code. Amazing.

But what was all that stuff about xmlrpc, package managers and such like. Well it appears that php now includes support for xmlrpc using Dan Libby's epi library. And because of that the PEAR guys assume it's there and use it in the package manager. And the php install docs say just use --xmlrpc(=DIR) as a config parameter. Well of course, I'd tidied up all the source, so download and untar the php source again. Add the parameter, check ./configure. Except that some of the xmlrpc responses look incomplete. Run make anyway, Bang! iconv.h missing. What? What happened then? Maybe I'm supposed to install xmlrpc-epi.c first. Download that, untar, configure, make, Bang! The Makefile borks with some impenetrable message. So it's off to the sourceforge pages, where I find a whole lot of equally impenetrable messages about how maybe FreeBSD is odd. Or maybe this or maybe that. But nothing that says "Do it like this and it'll work"

Now core PHP is really good. The docs are great, the code works, the install works. But step off the beaten track and we're back into Nerdland where it's assumed that you "Have a Clue", can debug other people's makefiles and can just know what to do by some weird telepathic osmosis.

Postscript: What I really wanted to do is put some cool Googley SOAP code into Theecademy.com But I have even less control there and they're running php 4.0.6 with no hope of getting an upgrade and no PEAR. But I copied all the useful files across, used a line in .htaccess to set the include_path. The test code said "requires PHP 4.1 or higher". Oh really? Comment out that check and it says array_key_exists() not found. And the php manual says "The name of this function is key_exists() in PHP version 4.0.6" So global search and replace through all of PEAR/SOAP and Bingo! Googley search results.


[ << Netmaster 10baseT is in the house ] [ Whew! >> ]
[ 15-Apr-02 4:28pm ]