You are here:  » Magicparser Not working with this rss

Support Forum



Magicparser Not working with this rss

Submitted by fraizor on Mon, 2016-10-24 12:12 in

hi
a wired thing that the demo is working but the default generated php cpde is not working for this url

{link saved}

<?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["ITEM"];
    print 
$record["GUID"];
    print 
$record["TITLE"];
    print 
$record["LINK"];
    print 
$record["PUBDATE"];
    print 
$record["DESCRIPTION"];
  }
  
MagicParser_parse("http://www.example.com/news_rss.php","myRecordHandler","xml|RSS/CHANNEL/ITEM/");
?>

any ideas ?

Submitted by support on Mon, 2016-10-24 16:29

Hi,

As with the previous RSS that you were not able to fetch, the example code is working fine on my test service. I see from the source code that you posted regarding the maximum number of calls to MagicParser_parse() that you are setting the user agent so that should not be the problem.

What I would suggest therefore is trying the CURL equivalent, which would be:

<?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["ITEM"];
    print 
$record["GUID"];
    print 
$record["TITLE"];
    print 
$record["LINK"];
    print 
$record["PUBDATE"];
    print 
$record["DESCRIPTION"];
  }
  
$url "http://www.example.com/news_rss.php";
  
$ch curl_init($url);
  
curl_setopt($chCURLOPT_HEADER0);
  
curl_setopt($chCURLOPT_RETURNTRANSFER1);
  
$xml curl_exec($ch);
  
curl_close($ch);
  
MagicParser_parse("string://".$xml,"myRecordHandler","xml|RSS/CHANNEL/ITEM/");
?>

(don't forget to change www.example.com to the host / domain name of your feed)

Hope this helps!
Cheers,
David
--
MagicParser.com

Submitted by fraizor on Tue, 2016-10-25 12:47

Great thanks ...