Page 1 of 1

Reading Response from URL

Posted: Mon Nov 07, 2005 5:04 pm
by cyberstryke
hello all,

I`m am expecting to submit a migration info to a remote URL which will then migrate the information

my php code that automatically send the info through a loop (thanks to sami and Yum jelly) looks like this:

Code: Select all

<?

    ignore_user_abort ( 'true' );
    set_time_limit ( 0 );


for ($i=0;$i<10;$i++) //this is just a dummy loop..

{


$html=file_get_contents('http://10.1.1.228/migrate/target.php?i='.$i);

}

?>
the target.php file is the file that will insert the record on their end.

Instructions given by thrid party company (where the data is being sent) says:


A successful migration will result in this response:
errorCode=0
errorMsg=None


If there is a problem, the response will be:
errorCode=1 (or other appropriate numeric value)
errorMsg=Description of error

my problem here is how do i read the response. do I simply make use of $_REQUEST to get the appropriate values? Any suggestion plz?

Is it possible for me to simulate this on my internal lan....eg the target.php file i`ve written inserts the value submitted in a database. But what shall i return upon successful execution of the insert query?


Thanks in advance

Posted: Mon Nov 07, 2005 7:36 pm
by feyd
the response is in $html..

simply use substr() to remove the leading "errorCode=" then see if the remaining is non-zero..

Posted: Mon Nov 07, 2005 8:04 pm
by cyberstryke
okie feyd i`ll try this and see if it works.

thanks a lot