Reading Response from URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cyberstryke
Forum Newbie
Posts: 15
Joined: Sun Nov 06, 2005 1:34 pm

Reading Response from URL

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the response is in $html..

simply use substr() to remove the leading "errorCode=" then see if the remaining is non-zero..
cyberstryke
Forum Newbie
Posts: 15
Joined: Sun Nov 06, 2005 1:34 pm

Post by cyberstryke »

okie feyd i`ll try this and see if it works.

thanks a lot
Post Reply