Jump to content

[Solved] PHP get, parsing rss into a html5 player


Mercifull

Recommended Posts

[hide]Hi all,

 

Been a long time posting in this forum but I've come across something that I'm stumped at and could do with some advice. Let me explain some bits...

 

I have running on the server some software called DirCaster which reads the contents of folders to create an RSS feed. e.g. I have a folder on fromefm.co.uk/media/altfactor full of mp3 files. DirCaster created this on the fly when you put the folder in as a variable. See http://fromefm.co.uk...?show=altfactor

 

I am using an RSS parser called MagpieRSSwhich if I hardcode in the rss url works fine but doesn't work If I try to use _GET to change it.

 

<?php

require_once 'magpierss/rss_fetch.inc';
$url = 'http://fromefm.co.uk/archive/dircaster2.php?show=altfactor';
$rss = fetch_rss($url);
foreach ($rss->items as $item ) {
$title = $item[title];
$url = $item[guid];
$description = $item[description];
echo "<li><a href='#' data-src='$url'>$title</a></li>
";
}
?>

 

The above code successfully lists all the stuff in the podcast directory by running the magpie script which in turn runs dircaster to get the file listing. The problem arises when trying to make the $url variable dynamic.

 

I thought I could just do this to create my own new dynamic variable

$showname = $_GET['show'];

 

But when I put it into the main code it breaks.

 

<?php
$showname = $_GET['show'];
require_once 'magpierss/rss_fetch.inc';
$url = 'http://fromefm.co.uk/archive/dircaster2.php?show='+$showname;
$rss = fetch_rss($url);
foreach ($rss->items as $item ) {
$title = $item[title];
$url = $item[guid];
$description = $item[description];
echo "<li><a href='#' data-src='$url'>$title</a></li>
";
}
?>

 

I hope this makes sense. I've got an example page here which DOES have the variable to get a show name but still has the dircaster url hardcoded. There is an echo of $showname in the description to check it works. e.g http://www.frome.me/....php?show=tipit

 

Any ideas or advice would be helpful. Perhaps it's something MAgpie can't do. If so are there any other similar RSS->PHP parsers around that could do this?[/hide]

Solved. Thanks

 

 

Working (draft) script here: http://www.fromefm.c...er/?show=xxxxxx

 

examples:

http://www.fromefm.c...?show=altfactor

http://www.fromefm.c...=homelyremedies

http://www.fromefm.c.../?show=ourhouse

 

Thanks for the help guys.

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

Link to comment
Share on other sites

I should probably explain it's to basically parse the contents of the RSS into a playlist that audiojs can read.

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

Link to comment
Share on other sites

Does '+' even concatenate in php? Try this:

 

<?php
$showname = $_GET['show'];
require_once 'magpierss/rss_fetch.inc';
$url = 'http://fromefm.co.uk/archive/dircaster2.php?show='.$showname;
$rss = fetch_rss($url);
foreach ($rss->items as $item ) {
$title = $item[title];
$url = $item[guid];
$description = $item[description];
echo "<li><a href='#' data-src='$url'>$title</a></li>
";
}
?>

  • Like 1
Link to comment
Share on other sites

Awsome! Thanks. I was soooooooooooooooooooo close to being right lol. Schoolboy error :) Thanks very much

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

Link to comment
Share on other sites

You are trying to concatenate two strings in the wrong way. In JavaScript you would indeed use a + sign, but in PHP the concatenation operator is a period. Change the line to this and it will work

 

$url = 'http://fromefm.co.uk/archive/dircaster2.php?show='.$showname;

 

... and I see the answer was already posted during me posting my response :P

Edited by Xena_Dragon
  • Like 1

Xena_Dragon.png

Link to comment
Share on other sites

Now begins the challenge of turning all my experiments into a Wordpress plugin eek

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

Link to comment
Share on other sites

It's because I've been flicking between php and javascript for this blinkin html5 player I used a + instead of .

 

Now I understand how women get so stressful when you have a missing period.

  • Like 1

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

Link to comment
Share on other sites

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.