You are here:  » Can not get same results as online demo


Can not get same results as online demo

Submitted by Strikeplate on Wed, 2009-07-15 18:50 in

Greetings,

In trying your online demo I was able to get the exact results I'm looking for on a file I need to parse. However, after buying the product and using the PHP generator code all I get is a blank page. Here is the generated code:

<?php
  
require("MagicParser.php");
  function 
myRecordHandler($record)
  {
    
// This is where you write your code to process each record, such as loading a database
    // You can display the record contents using PHP's internal print_r() function:
    
print_r($record);
    
// The following code will print out each field in your sample data:
    
print $record["DEALERS"];
    print 
$record["PRIMARYDEALER"];
    print 
$record["PRIMARYDEALER/DEALERCODE"];
    print 
$record["PRIMARYDEALER/DEALERCODE-VALUE"];
    print 
$record["PRIMARYDEALER/DEALERNAME"];
    print 
$record["PRIMARYDEALER/DEALERNAME-VALUE"];
    print 
$record["PRIMARYDEALER/PRODUCTLINES"];
    print 
$record["PRIMARYDEALER/PRODUCTLINES/PRODUCTLINE"];
    print 
$record["PRIMARYDEALER/PRODUCTLINES/PRODUCTLINE-VALUE"];
    print 
$record["PRIMARYDEALER/ZONECODE"];
    print 
$record["PRIMARYDEALER/ZONECODE-VALUE"];
    print 
$record["PRIMARYDEALER/DEALERADDRESS"];
    print 
$record["PRIMARYDEALER/DEALERADDRESS/ADDRESSLINE"];
    print 
$record["PRIMARYDEALER/DEALERADDRESS/ADDRESSLINE-LINEID"];
    print 
$record["PRIMARYDEALER/DEALERADDRESS/ADDRESSLINE-VALUE"];
    print 
$record["PRIMARYDEALER/DEALERADDRESS/ADDRESSLINE@1"];
    print 
$record["PRIMARYDEALER/DEALERADDRESS/ADDRESSLINE@1-ERRORCODE"];
    print 
$record["PRIMARYDEALER/DEALERADDRESS/ADDRESSLINE@1-LINEID"];
    print 
$record["PRIMARYDEALER/DEALERADDRESS/POSTALCODE"];
    print 
$record["PRIMARYDEALER/DEALERADDRESS/POSTALCODE-VALUE"];
    print 
$record["PRIMARYDEALER/DEALERADDRESS/PROVINCECODE"];
    print 
$record["PRIMARYDEALER/DEALERADDRESS/PROVINCECODE-VALUE"];
    print 
$record["PRIMARYDEALER/HISPEED"];
    print 
$record["PRIMARYDEALER/HISPEED-VALUE"];
    print 
$record["PRIMARYDEALER/INHERITEDDEALERS"];
    print 
$record["PRIMARYDEALER/CALIBRE"];
    print 
$record["PRIMARYDEALER/CALIBRE-VALUE"];
  }
  
MagicParser_parse("{link saved}","myRecordHandler","xml|SSORES:SSORESPONSE/USERPROFILE/DEALERS/");
?>

I am putting this code in a file named "response.php" and when I browse to it...nothing. Please note that the only change I made to the code above is to make the path to MagicParser.php absolute, because this domain is load balanced across 3 servers and it seemed to hang up with the relative path.

I'm in a jam...hope you can help!

Thanks!

Submitted by support on Wed, 2009-07-15 19:16

Hello!

This is almost certainly because your web server is not permitting fopen() to access Internet URLs. The first thing to try would be to display the Magic Parser error message as follows;

  MagicParser_parse("{link saved}","myRecordHandler","xml|SSORES:SSORESPONSE/USERPROFILE/DEALERS/");
  print MagicParser_getErrorMessage();

If that indicates that the file could not be opened, that would imply the above. You can find more information about the settings on the following page:

http://uk2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen

However, it is becoming more common for PHP installations to have CURL compiled in, which is an alternative method for accessing Internet URLs. An alternative to the above code using CURL would be as follows:

  $url = "{link saved}";
  $ch = curl_init($url);
  curl_setopt($ch,CURLOPT_HEADER, 0);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
  $xml = curl_exec($ch);
  MagicParser_parse("string://".$xml,"myRecordHandler","xml|SSORES:SSORESPONSE/USERPROFILE/DEALERS/");

Don't forget to replace {link saved} with your URL!

Hope this helps,
Cheers,
David.