You are here:  » How come your demo form waits for the response and mine not


How come your demo form waits for the response and mine not

Submitted by c_figer on Thu, 2007-03-22 10:05 in

Hi Dave -

im trying to put together a simple form that submits this url:

[link]

to receive an xml response from it - the problem i have is that my form after submitting loads right away without waiting for the response but your form is actually waiting for the called site to respond - try it yourself - and replace the number var with your phone number and see it for yourself on the demo site you have -

why is your form hangs on until some response gets back to it - when mine simply loads without waiting for the response? what am i doing wrong?

cheers, Kei

Submitted by support on Thu, 2007-03-22 10:14

Hello Kei,

To help you here I would need to know how you have written the code to request the remove URL. Can you post the snippet of PHP you are using that requests the page before parsing it; for example if you are doing:

<?php
  MagicParser_parse
("[URL HERE]","myRecordHandler");
?>

If this is how you are doing it, it may be that URL wrappers are not enabled on your server. Have a look at the following thread for more info and links...

http://www.magicparser.com/node/189

Cheers,
David.

Submitted by c_figer on Thu, 2007-03-22 10:45

thanks dave,

here is what i got:

<? if (isset($_POST['pcok'])) {
require("MagicParser.php");
function myRecordHandler($item) {
$ProcessingStage = $item['PROCESSINGSTAGE'];
$ConfiramtionResult = $item['CONFIRMATIONRESULT'];
$PIN = $item['PIN'];
$TransactionID = $item['TRANSACTIONID'];
echo $ProcessingStage."--".$ConfiramtionResult."--".$PIN."--".$TransactionID; //debugger
}
$url=trim($_POST['url']);
MagicParser_parse($url,"myRecordHandler","xml|JOBSTATUS/");
echo MagicParser_getErrorMessage();
} else {
$a=range(0,9);
shuffle($a);
$pc_pin="";
$pc_pin.=$a[0];
$pc_pin.=$a[1];
$pc_pin.=$a[2];
$pc_pin.=$a[3];
$pc_pin.=$a[4];?>
<fform name="pcform" method="post">
<input name="url" type="hidden" value="<?="http://www.phoneconfirm.com/soap/HTTPHandlers/play.aspx?guid=".$setts['pc_guid']."&number=".$user['phone']."&Text=This+is+a+call+To+Complete+Phone+Verification+please+enter+the+pin+as+shown+on+the+site+and+press+pound+sign+once+done&Pin=".$pc_pin."&TransactionID=".$_SESSION['memberid']."&type=Confirmation";?>">
<input type="submit" name="pcok" value="OK"></TD>
</fform>
<? } ?>

it does not seem to be any problem in general but you might find something - a fresh eye is always a sign of relief - if you know what i mean -

(i omitted some php vars since they only fill the params of the url which can be tested with some fixed values - you know that anyway )

cheers, Kei

NOTE - i have to replace form tags with fform words otherwise i couldnt post anything in this topic -

Submitted by support on Thu, 2007-03-22 10:56

Hello Kei,

I notice you are printing MagicParser_getErrorMessage(). I assume that there is no error dispayed? Otherwise this would indicate that URL wrappers are disabled on your server...

Cheers,
david.

Submitted by c_figer on Thu, 2007-03-22 11:21

yes - but the form loads instantly after submit - without any waiting for the response - so the MagicParser_getErrorMessage() - does not even get to show anything - it seems that the $url variable does not get inserted into - MagicParser_parse($url,"myRecordHandler","xml|JOBSTATUS/"); -

Submitted by support on Thu, 2007-03-22 11:25

Hi,

I would insert some debug code to look at $url immediately before calling Magic Parser, for example:

print $url;exit();

Does this display the URL correctly?

Cheers,
David.

Submitted by c_figer on Thu, 2007-03-22 11:53

yes i have that debugger inserted right above parser

$url=$_REQUEST['url'];
echo $url.""; //debugger
MagicParser_parse($url,"myRecordHandler","xml|JOBSTATUS/");

and yes i can see it echo'ed to the window - thats pretty all i can see printed to the screen - page just loads - progress bar gets 100% - and the status bar says Done - nothing else - :(

Submitted by support on Thu, 2007-03-22 11:59

Hi,

I would write a test script here to just try and parse the file, nothing else. For example:

<?php
  
require("MagicParser.php");
  function 
myRecordHandler($record)
  {
    print 
"Got Job Status Response";
  }
  
$url "TEST-URL-HERE";
  
MagicParser_parse($url,"myRecordHandler","xml|JOBSTATUS/");
?>

For TEST-URL-HERE, use the same example link as you posted in your first message. If this doesn't work, we'll take it a step further and write raw PHP code to try and fopen() the remove file in exactly the same way that Magic Parser does..

Cheers,
David.

Submitted by c_figer on Thu, 2007-03-22 12:52

nada - nothing shows - even with a hard-coded url - as per above

Submitted by support on Thu, 2007-03-22 13:12

Hi,

This means that it is one of 2 things;

1) URL wrappers are not enabled on your system.

2) A firewall is preventing access to that URL from your system.

In order to find out which, we need a test script to simply load the
XML from the remote server and display it. Firstly, try the following
script:

<?php
  
function test($url)
  {
    
$file fopen($url,"r");
    if (!
$file)
    {
      print 
"<p>Failed to open ".$url."</p>";
      return;
    }
    
$data "";
    while(!
feof($file)) $data .= fread($file,1024);
    
fclose($file);
    print 
"<p>Successfully opened ".$url.", read ".strlen($data)." bytes.</p>";
  }
  
test("http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml");
  
test("YOUR-EXAMPLE-URL");
?>

Replace YOUR-EXAMPLE-URL with the link in your first post.

If neither URL can be opened (BBC News or your example link), it almost
certainly means that URL wrappers are disabled on your server.
The links in the following thread will give you more information:

http://www.magicparser.com/node/189

If the first URL works but the second one (your example URL) doesn't, then it implies that there may be a firewall issue between your server and the web service...

Hope this helps!
Cheers,
David.

Submitted by c_figer on Thu, 2007-03-22 13:20

ok - i got just this:

Successfully opened http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml, read 13143 bytes.

Submitted by support on Thu, 2007-03-22 13:24

Did you also get on the next line:

Failed to open YOUR-EXAMPLE-URL

?

Cheers,
David.

Submitted by c_figer on Thu, 2007-03-22 13:28

no - just that one - nothing else -

i started thinking that MP wont parse delayed responses - unless there is something to keep it checking the url for status of the response -

Submitted by support on Thu, 2007-03-22 13:30

Hi Kei,

From the tests we've done we know the problem is nothing to do with Magic Parser. Your server has a lower level issue accessing that URL.

I'm now trying to help you work out what that is so that you can then use this URL with Magic Parser.

Back to the test script, remove the BBC link because we know that works. Now try it with just your example URL:

<?php
  
function test($url)
  {
    
$file fopen($url,"r");
    if (!
$file)
    {
      print 
"<p>Failed to open ".$url."</p>";
      return;
    }
    
$data "";
    while(!
feof($file)) $data .= fread($file,1024);
    
fclose($file);
    print 
"<p>Successfully opened ".$url.", read ".strlen($data)." bytes.</p>";
  }
  
test("http://www.phoneconfirm.com/soap/HTTPHandlers/play.aspx?guid=69c463dd7b8c43c991718916d1d2bb47&number=12121234567&Text=This+is+a+call+To+Complete+Phone+Verification+please+enter+the+pin+as+shown+on+the+site+and+press+pound+sign+once+done&Pin=25813&TransactionID=1&type=Confirmation");
?>

What output do you see this time?

Cheers,
David.

Submitted by c_figer on Thu, 2007-03-22 14:10

just a blank screen - no errors - no response - nada-

Submitted by support on Thu, 2007-03-22 14:26

Hi,

That implies that PHP is failing silently when trying to open that URL. Can you try this version:

<?php
  
function test($url)
  {
    print 
"<p>Opening File...</p>";
    
$file fopen($url,"r");
    if (!
$file)
    {
      print 
"<p>Failed to open ".$url."</p>";
      return;
    }
    
$data "";
    while(!
feof($file)) $data .= fread($file,1024);
    
fclose($file);
    print 
"<p>Successfully opened ".$url.", read ".strlen($data)." bytes.</p>";
  }
  
test("http://www.phoneconfirm.com/soap/HTTPHandlers/play.aspx?guid=69c463dd7b8c43c991718916d1d2bb47&number=12121234567&Text=This+is+a+call+To+Complete+Phone+Verification+please+enter+the+pin+as+shown+on+the+site+and+press+pound+sign+once+done&Pin=25813&TransactionID=1&type=Confirmation");
?>

This should at least show "Opening file...". What do you see on your server?

Cheers,
David.

Submitted by c_figer on Thu, 2007-03-22 14:34

i see only this:

Opening File...

Submitted by support on Thu, 2007-03-22 14:37

Hi Kei,

Do you understand what you are seeing here?

PHP is crashing when you try to fopen() that particular URL.

Do you have access to the error log for your website? If so, can you have a look in that and see if there is any additional information...

Cheers,
David.

Submitted by c_figer on Thu, 2007-03-22 15:12

ohh yes - just got to see this one:

[22-Mar-2007 10:03:16] PHP Warning: fopen(http://www.phoneconfirm.com/soap/HTTPHandlers/play.aspx?guid=69c463dd7b8c43c991718916d1d2bb47&number=12121234567&Text=This+is+a+call+To+Complete+Phone+Verification+please+enter+the+pin+as+shown+on+the+site+and+press+pound+sign+once+done&Pin=25813&TransactionID=1&type=Confirmation) [function.fopen]: failed to open stream: HTTP request failed! in /home/xxx/public_html/xxx/pcl.php on line 41

but how come it does not crash when you go directly to that site using the above url link?

Submitted by support on Thu, 2007-03-22 15:44

Hello Kei,

The real question is why is PHP only failing to open this particular URL, as it opens the BBC news URL successfully.

I can confirm that it works on my server:

Opening File...
Successfully opened [snipped] read 315 bytes.

I think it is possible that phoneconfirm.com have restricted access to their web service from your server's IP address. I would consider contacting them to see if they do this, and let them know the IP address of your server...

Cheers,
David.

Submitted by c_figer on Thu, 2007-03-22 16:58

hi dave - that maybe obvious for me not for you - but i get the verification call when that page is accessed from my server - but that page does not load right away on your server - it is waiting for my repsonse to answer and type the verfivication code on the phone pad - but on my server the page does not wait for my input from phone pad and loads right instantly - basically the url is accessed from my server (it is not blocked by phoneverificator) - so your server reaches them and my server reaches them - but your form does not load until some response comes back from them - but my form does not wait for any response - thats why i dont think it is the problem of being blocked or not - it is the problem of not waiting for the final response which might take a few dosen seconds before the xml is returned from phoneverificator - and here is all boils down to the questions is what can be done to make sure the MP will parse long waiting time response -

cheers, Kei

Submitted by support on Fri, 2007-03-23 12:53

Hello Kei,

I'll have a look around the web and see if I can find any
reason why fopen() is might not be working for your particular URL.

Just to reiterate, this is nothing that can be fixed within Magic
Parser because our test scripts above proved that it is a much lower
level issue with your server that is the problem.

However, I will if you wish refund your purchase of Magic Parser if
you are not able to use it in this scenario. Please let me know if you
would like me to do this.

I will have a search and see if I can find any clues!

Cheers,
David.