You are here:  » Is this the backend to feedprocessor


Is this the backend to feedprocessor

Submitted by dflsports on Fri, 2005-12-02 15:51 in

A while back I demo'ed the feedprocessor. You might remembeme from ABW and I had asked about some xml feeds which you promptly were able to parse.

So I take it to use this script you need to have a little knowledge of php? I am clueless but trying to learn.

Will it be possible, with this script to take an xml feed (in addition to normal csv feeds like thos offered at shareasale) and convert it to a usable csv file and/or inport directly into mysql. Mysql is a whole new set of problems I am trying to overcome :)

What I am alos looking to do is convert a xml datafeed into a usable rss format. Will this be possible with magicparser?

Thank you very much for your help, i know last time you were very helpful. I never really used the feed processor because I am exploring more dynamic ways of getting my sites updated. That is why magic parser caught my attention. BTW, I found the script at hotscripts.

Don

Submitted by support on Fri, 2005-12-02 16:42

Hi Don,

Yes, this is basically the "back end" to FeedProcessor.com! I received so many requests for the parsing script as a stand-alone that i've now decided to publish it through this website.

You will notice, however, that i'm not focussing on the affiliate site of things so much as the script works just as well with any XML or text file feeds - including RSS.

Click here for a simple affiliate datafeed to database example - very basic but it should give you some pointers.

You could certainly use it to convert an XML feed into RSS. Let me roll some example code and i'll get back to you.

PS - have you got your download working now? I have renamed the script to have the .o extension instead of .php as many FTP clients autodetect PHP as the ASCII format.

Submitted by dflsports on Fri, 2005-12-02 17:08

I think I do. I used SSH (first time, yippee) and I have the files on the server and they are there. I see

Array ( [DEMO] => [MESSAGE] => If you can read this message your Magic Parser installation is working! )

on the php test page and the xml page works too. So now I just have to try some example code.

Thanks for the quick response.

Don

Submitted by support on Sat, 2005-12-03 11:21

Ok, this is as good an excuse as any to test the PHP posting module of Drupal. Here's how you could generate a very basic RSS format XML feed from an affiliate product feed:

<?php
  
require("MagicParser.php");
  
// set the output content-type to text/xml
  
header("Content-Type: text/xml");
  
// print the RSS header
  
print "<rss version='2.0'>";
  print 
"<channel>";
  print 
"<title>Some Title</title>";
  function 
myRecordHandler($product)
  {
    print 
"<item>";    
    print 
"<title>".$product["ProductName"]."</title>";
    print 
"<description>".$product["ProductDesc"]."</description>";
    print 
"<link>".$product["AffiliateURL"]."</link>";
    print 
"</item>";
  }
  
// parse the feed - myRecordHandler prints each RSS item
  
MagicParser_parse("/path/to/feed.xml","myRecordHandler");
  
// print the RSS footer
  
print "</channel>";
  print 
"</rss>";
  exit();
?>

To make this work with your own feed, you would need to modify the keys used when extracting the product name, description and affiliate URL fields from $product in myRecordHandler.

It would also help to use a suitable format string for the feed.

Hope this helps!

Submitted by dflsports on Sat, 2005-12-03 19:11

I'll give it a try, thanks a million :)

Don

Submitted by dflsports on Thu, 2005-12-08 05:32

Well, It took alot of tweaking because data problems and rss specs but I have imported a csv and created a rss feed. Thanks again for the code.

I do have a question. Would it be possible to "map" two fields to one rss tag?

Like if I wanted to add another field to the description tag

<?php
print "<description>".$product["ProductDesc"]."  - ????add another field here????</description>";
?>

I tried a few things, well lots of thnigs actually and can't get it to add text from another field.

I know I can merge files before importing to magicparser, but I have to do that manually for feeds emailed to me. So I was hoping to use magicparser to merge to fileds into one rss tag.

Submitted by support on Thu, 2005-12-08 08:12

Hi Don,

You just need to use the dot operator to concatenate strings in PHP, so you could use, for example:

<?php
print "<description>".$product["ProductDesc"] . " - " $product["ProductName"]."</description>";
?>