You are here:  » RCS Feed


RCS Feed

Submitted by JohnL58 on Fri, 2006-01-27 22:25 in

First off, I would like to say thanks for writing a great script which took me about 4 months to find the right one (fingers crossed).

I read through the site and got most of the information that I needed, but there are still a couple of questions I have prior to purchasing.

1. Of the data in the xml file:
<PLAYBACKSTATE>
<TRIGGER>PLAY</TRIGGER>
<CURRENTTIME>01/27/06 14:07:07</CURRENTTIME>
<PLAYLIST>012706N</PLAYLIST>
<PLAY INDEX="0">
<CUTID>98104</CUTID>
<TYPE>P</TYPE>
<AUTOCODE>S</AUTOCODE>
<TITLE>EN TU SONRISA</TITLE>
<OUTCUE>JOAN SEBASTIAN</OUTCUE>
<AGENCY>MUSART</AGENCY>
<USERDEF>DAD</USERDEF>
<LENGTH>3:05.0</LENGTH>
<GROUP>MUSICA</GROUP>
<BILLBOARD />
<ARTIST />
</PLAY>
</PLAYBACKSTATE>

I only need the <TITLE> </TITLE> and the <OUTCUE></OUTCUE> data to be shown on our website. This is really the title of the song and the artist. Can I separate the displayed data just to show the title and outcue, while not showing the remaining data?

2. The way the data is shown, with the existing script, are there ways of changing the layout of the displayed data?

Thanks in advance,
John L Wilson

Submitted by support on Fri, 2006-01-27 22:36

Hello John,

Thank you for your interest in Magic Parser.

There is no problem at all in just extracting and displaying the contents of selected tags. In fact, you need to write code to specifically display each tag.

The demo script here on MagicParser.com uses a loop to go through and display all the fields in each record in a table (using PHP's foreach construct); but what you do in your own code is up to you.

For example, here is a snippet that would just print the TITLE and OUTCUE from your RCS feed:

<?php
  
require("MagicParser.php");
  function 
myRecordHandler($record)
  {
    print 
"<p>";
    print 
"Title: ".$record["TITLE"]."<br>";
    print 
"Outcue: ".$record["OUTCUE"]."<br>";
    print 
"</p>";
  }
   
MagicParser_parse("campesina.xml","myRecordHandler","xml|PLAYBACKSTATE/PLAY/");
?>

(note that i've removed the URL from the XML file)

The formatting and the way that you actually generate the HTML within the myRecordHandler function is entirely up to you!

Hope this helps,
Regards,
David
--
Developer, Magic Parser

Submitted by JohnL58 on Fri, 2006-01-27 22:41

Awesome, I am purchasing the script now...thanks so much for the very prompt response, information and great script.

John L Wilson

Submitted by JohnL58 on Fri, 2006-01-27 23:00

Ummmmm, I think I spoke too soon -
When I ran the script in the demo, it worked just fine, but when I ran it in my site, it doesn't work...

I am calling the xml file from a remote server and not my local server: http://64.171.139.30/streaming/campesina.xml

I changed the line to read:
MagicParser_parse("http://64.171.139.30/streaming/campesina.xml","myRecordHandler","xml|PLAYBACKSTATE/PLAY/");

Any help would be greatly appreciated.

John L Wilson

Submitted by support on Fri, 2006-01-27 23:08

Hi John,

Don't worry - i'm sure we can get you working!

The first thing; your installation of PHP may not have URL wrappers enabled which is required in order to open a file from a remote URL.

In order to find out if that is the case; the first thing to do is to download the XML through your web browser and save it as a local file on your PC (called something like campesina.xml). Then, upload that file into the same directory as your test script and remove the URL component from the filename paramters. This will leave you with just:

MagicParser_parse("campesina.xml","myRecordHandler","xml|PLAYBACKSTATE/PLAY/");

Now, to debug further you can use the getErrorMessage function. Building on my previous example, use the following code to help get debug information from MagicParser:

<?php
  
require("MagicParser.php");
  function 
myRecordHandler($record)
  {
    print 
"<p>";
    print 
"Title: ".$record["TITLE"]."<br>";
    print 
"Outcue: ".$record["OUTCUE"]."<br>";
    print 
"</p>";
  }
  
MagicParser_parse("campesina.xml","myRecordHandler","xml|PLAYBACKSTATE/PLAY/");
  print 
"<p>Magic Parser Error Message: ".MagicParser_getErrorMessage ()."</p>";
?>

Hope this helps. Assuming that the problem is URL wrappers, can you let me know what version of PHP you are using so that I can check-up on the required PHP config in order to make it work using a URL...

Submitted by JohnL58 on Fri, 2006-01-27 23:17

Hi,
The script is working fine when I run it from my server: http://www.campesina.net/feeds/

I believe the version of Php is ver. 4 and above, I don't know about ver. 5, but they are pretty much up to par.

There was two other questions:
There is a CUTID tag which reflects if it is a song or not, and the numbers 9XXXXX are songs they want to show, anything with a 1XXXX they don't want to display, as this is their commercials, can this be done?

Thanks in advance,
John L Wilson

Thanks,
John L Wilson

Submitted by support on Fri, 2006-01-27 23:23

No problem with the selective display; you'd need to write an IF statment, based on the first character of $record["CUTID"] a la:

<?php
  
require("MagicParser.php");
  function 
myRecordHandler($record)
  {
    if (
substr($record["CUTID"],0,1)=="9")
    {
      print 
"<p>";
      print 
"Title: ".$record["TITLE"]."<br>";
      print 
"Outcue: ".$record["OUTCUE"]."<br>";
      print 
"</p>";
    }
  }
   
MagicParser_parse("campesina.xml","myRecordHandler","xml|PLAYBACKSTATE/PLAY/");
?>

I'll check over the required PHP config for URL wrappers...

Submitted by JohnL58 on Fri, 2006-01-27 23:38

Awesome, the CUTID works marvellously...thanks so much.

With regards to the script, I am running it off another server of mine and it works just fine...
http://nationalchavezcenterorg.nfwscedu.com/feeds/

If anything, I can run it this way if there is no success on your end regarding the original server. I will wait for your response though,

John L Wilson

Submitted by support on Fri, 2006-01-27 23:48

Excellent - glad you're up and working! Regarding the other server;

If you could create a script to display the output of phpinfo() you can see if URL wrappers are enabled. If you upload the following script to your server:

<?php
  phpinfo
();
?>

...run the script, and look down the page for "allow_url_fopen". The first thing to is check to see if that is set to "On".

If it is off, you will need to edit php.ini on that server. The docs are here:

http://uk2.php.net/manual/en/ini.php

In your php.ini file (on a Linux server this is normally in the /etc/ directory), look for the line with allow_url_fopen, and set the value to 1, assuming that it is not already. Don't forget that you will need to restart your web server before any changes made in php.ini take effect.

If you are running the script on a hosting account and do not have access to php.ini you may need to contact your web host and ask them to enable URL wrappers for you.

First step is the phpinfo() script - let me know how you get on with that...

Hope this helps,
Regards,
David.

Submitted by JohnL58 on Fri, 2006-01-27 23:59

I see what you mean...the script reads:
allow_url_fopen Off Off

so long as I have it running off of the other server that is fine. They are all one organization.

Final question, the I will leave you alone (fingers crossed), it is showing the last 5 or 6 listings, and that is fine for one page we are creating called last played.

Is there a snippet which will only run one current listing and not 5 or 6, then we can run both scripts?

Thanks so much again, and this was a great experience all around,
John L Wilson

Submitted by support on Sat, 2006-01-28 00:02

Sure; you could stop it after just 1 listing by making the myRecordHanlder function return true. This stops Magic Parser from reading any more records. Of course, you only want to do this if the CUTID is one of the ones you want to display; so adapting the previous snippet:

<?php
  
require("MagicParser.php");
  function 
myRecordHandler($record)
  {
    if (
substr($record["CUTID"],0,1)=="9")
    {
      print 
"<p>";
      print 
"Title: ".$record["TITLE"]."<br>";
      print 
"Outcue: ".$record["OUTCUE"]."<br>";
      print 
"</p>";
      return 
true;
    }
  }
   
MagicParser_parse("campesina.xml","myRecordHandler","xml|PLAYBACKSTATE/PLAY/");
?>

Hope this helps!
Rgds,
David.

Submitted by JohnL58 on Sat, 2006-01-28 00:11

Works like a charm...thanks very much.

I called the server tech support of the original server and they are sending me an .htaccess snippet to enable URL wrappers.

Thanks again and the radio stations thanks you...
John L Wilson

Submitted by JohnL58 on Mon, 2006-01-30 20:15

Hi David,
I sent you a personal email...

Thanks so much!