Page 1 of 1

Poor Man's Webservice

Posted: Wed Oct 22, 2008 7:41 pm
by jeffrydell
I've been working on a 'quick and dirty' webservice which sometimes works and sometimes doesn't ... perhaps someone here can supply the key which will unlock my mystery.

Website A is a client site. It calls a php script on the server for website B, where our MySQL database resides, like this:

Code: Select all

 
<?php
// Unique Identifier for this client...
$id = "me";
 
// Request the data...
$Reply = file("http://www.website_b.ws/something/webservice.php?id=".$id);
 
// Return the data to the screen...
echo $Reply[0];
?>
 
There's NO problem with that script at all - works flawlessly.

On the Website B server we have the script which verifies that the client request is coming from a legitimate referrer, pulls the data set for that client from the db, formats the data with appropriate markup for the client site, and uses echo to send the data stream back to the server for website A.

Sometimes.

I doubt this is the 'cause' that makes things work, but it may give you a clue.

If I include

Code: Select all

error_reporting("E_ALL");
at the top of the server script, then everything comes up exactly as it should on the requesting page. When I comment out the function, NOTHING gets streamed back to the client site.

I've been messing with php for several years now and have NEVER encountered anything like this. Then again, I've never tried to provide a webservice before either - so this just may be part of the 'learning curve'.

Anyone? Thoughts?

Thanks in advance for your help!

Jeff

Re: Poor Man's Webservice

Posted: Thu Oct 23, 2008 12:08 am
by Christopher
Sounds like you have some error message, perhaps notices, that are causing the server to produce bad output. Setting it to E_ALL causes them to not be generated. I would test the server script directly with a browser first to see what it is producing.