My question is very quick...
I see that this site has a section that automatically updates itself and lists "recent blog posts" on the home page.
How is this done?
Note: My blog is hosted separately form my site (through Blogger).
Thanks...
My question is very quick...
I see that this site has a section that automatically updates itself and lists "recent blog posts" on the home page.
How is this done?
Note: My blog is hosted separately form my site (through Blogger).
Thanks...
If you follow all the rules, you miss all the fun.
Sites: Bustout Dealer CASINOVILLE comics Playing Cards Sharps & Flats CARDSHARK Online CARDSHARK Online Blog Cardshark.TV NCIG The Mott Street Poker Club
If you want to go the PHP route, try SimplePie.
I use the script here... http://boastology.com/pages/mods.php ... the one at the bottom
You can see it in action here (slightly modified output) http://www.cameraphonereview.co.uk towards the bottom under latest cameraphone news
It works with different domains, so should fit the bill.
I also just looked at simplepie, but the demo did not seem to be working.
I use a generic RSS posting script. IT takes any RSS feed and can post it, I modified it as needed and just feed my blog's rss feed to it.
That type of setup will work for any blog, remotely hosted or otherwise.
Thanks, everyone...
Before I do any work on this, one more quick question.
Since my blog is remotely hosted, am I doing my main site a disfavor by having these outgoing links now? I know some of the PR will get sent back to my main site (page) because the blog has links to it, but I also know that some of the PR still gets lost.
So, do I stand to gain more form having this feature, than I stand to lose by leaking part of my PR?
What would be the general opinion on this issue?
Thanks...
If you follow all the rules, you miss all the fun.
Sites: Bustout Dealer CASINOVILLE comics Playing Cards Sharps & Flats CARDSHARK Online CARDSHARK Online Blog Cardshark.TV NCIG The Mott Street Poker Club
I wouldn't worry.
Your blog is remotely hosted, but that doesn't mean you do not control it. PageRank flows irregardless of domain, and in the grand scheme of things your blog will function, for PR flow, as if it were not remotely hosted and just another part of your site. Assuming you'll of course have links from your blog back to your site.
I'm afraid I'm not able to make any progress on this.
I looked at SimplePie but the whole thing was just confusing and unclear to me. I don't see any clear instructions on that site, that would tell me how to do this.
I downloaded http://boastology.com/pages/mods.php as Blue Cat Buxton suggested. I would really like to make this work, but there are absolutely no instructions for non-programmer like myself. It says the script is heavily commented, but to me its all Greek. There is one line that says "Enter the url to an RSS feed". I entered my feed's URL there. Then I uploaded that scrip to my server and tried to access it with my browser, to see what happens, and all I got was an error message. In any event, I would like to have the last posts of my blog appear on my home page, which is a static HTML page, and there are no instructions that explain how to do that (and I read all the comments in the script).
I also did a Google search for "RSS posting script" as Chris suggested, but wasn't able to make any sense of anything I found.
I'm kind of stuck...
Any help...?
If you follow all the rules, you miss all the fun.
Sites: Bustout Dealer CASINOVILLE comics Playing Cards Sharps & Flats CARDSHARK Online CARDSHARK Online Blog Cardshark.TV NCIG The Mott Street Poker Club
What was the error you got? I may be able to help.
Post here or send me a PM and I will see what I can do.
Thanks for looking into this.
The error message is "unclosed token".
The script is this:
I changed line 37 so that it has the URL of my feed.Code:<?php /*############################################## RSS parser written for bMachine feed. This script can be used to read ANY kind of RSS feeds from anywhere! *--------------------------------------------* Written by Kailash Nadh, http://bnsoft.net , kailash@bnsoft.net Author of bMachine, http://boastology.com I wrote this script on the 1st day I studied XML by running through the documentation at www.php.net ;) *--------------------------------------------* WARNING!: This script is Heavily commented! :) This is how the script works. > Reads the XML file > Parses it into an array using xml_parse_into_struct() > Converts that array into a more sensible, easily usable array [ See the structure.txt file to get an idea of the array structure ] > Finally, Display the data in anyway you want! This script demonstrates the use of simple logic to do Complex XML/RSS parsing functions This script can be easily developed into a powerful application. ##############################################*/ $url="http://feeds.feedburner.com/cardshark"; // Enter the url to an RSS feed $data=@fread(fopen("$url","r"),10000) or die("Cant open $url!"); // Get the file contents $myar=getXmlData($data); // What ever it may be, the argument to this // function should be the XML document's content // Now $myar holds the fully parsed XML contents. // It may have a number of tags, like <TITLE> , <LINK> , <AUTHOR> , <SOMETHING> ... and so on // With a simple loop, you can extract all the tags and their values neatly // Remember, $i<= should be lesser than or equal to the number of values // a tag has. If you give count($myar), it will only take the number of tags. // See structure.txt for better understanding. for($i=0;$i<=count($myar[TITLE]);$i++) { // Here, we want to read the TITLE, DESCRIPTION, and LINK of the RSS feed. // You can read the values of any tag like this. // $myar[TITLE][$i], $myar[SOMETHING][$i], $myar[SOMETAG][$i].... and so on.. // Here it goes $title=$myar[TITLE][$i]; $text=$myar[DESCRIPTION][$i]; $link=$myar[LINK][$i]; if($title) { echo <<<EOF <a href="$link"><font size="2" face="Verdana" color="blue">$title</font></a><br> <font size="2" face="Verdana">$text</font><br><br> <hr width="50%" size="1" align="left"> EOF; } } //##################################################################### // This is the function. It returns the array of the parsed XML data function getXmlData($xml_doc) { $n=0; // Counter used for arraying the XML data $ar=array(); // The main array for storing parsed xml using xml_parse_into_struct() // Parse the XML document $parser = xml_parser_create(); xml_parse_into_struct($parser,$xml_doc,$vals,$index) or die(xml_error_string(xml_get_error_code($parser))); xml_parser_free($parser); $ttags=array(); // Temporary arry for storing tag names // The main part. This is MY CREATION // and this piece of code makes this script simple :) // This is the "MAGIC LOOP" !! :) for($n=0;$n<=count($vals)-1;$n++) { if(trim($vals[$n][value])) { $ar[$vals[$n][tag]][count($ar[$vals[$n][tag]])]=$vals[$n][value]; $ttags[$vals[$n][tag]]=$vals[$n][tag]; } } // Array for storing all the tag names // This array will hold all the Tag names found in the XML document // eg: ("TITLE","LINK","AUTHOR","DOMAIN").. // Use this if you need it. $tags=array(); // Extract and save the tag names to the array foreach($ttags as $tagi) { array_push($tags,$tagi); } return $ar; } ?>
The script is currently uploaded here:
http://cardshark.us/scripts/rss-reader.php
Thank you for your time...
If you follow all the rules, you miss all the fun.
Sites: Bustout Dealer CASINOVILLE comics Playing Cards Sharps & Flats CARDSHARK Online CARDSHARK Online Blog Cardshark.TV NCIG The Mott Street Poker Club
This is the script I use... I think...
http://magpierss.sourceforge.net/
Modded of course. And obviously I could do better with special character encoding. Whatever. I actually don't 100% recall where I got it, But I think it is Magpie.
Here is the code
PHP Code:
<?php
/*##############################################
RSS parser written for bMachine feed.
This script can be used to read ANY kind of RSS feeds from anywhere!
*--------------------------------------------*
Written by Kailash Nadh,
http://bnsoft.net , kailash@bnsoft.net
Author of bMachine, http://boastology.com
I wrote this script on the 1st day I studied
XML by running through the documentation at www.php.net ;)
*--------------------------------------------*
WARNING!: This script is Heavily commented! :)
This is how the script works.
> Reads the XML file
> Parses it into an array using xml_parse_into_struct()
> Converts that array into a more sensible, easily usable array
[ See the structure.txt file to get an idea of the array structure ]
> Finally, Display the data in anyway you want!
This script demonstrates the use of simple logic
to do Complex XML/RSS parsing functions
This script can be easily developed into a powerful application.
##############################################*/
global $data;
// Enter the url to an RSS feed
$url="http://www.websitepublisher.net/blog/feed/";
//$file = $url;
//$ch = curl_init($file);
//$fp = @fopen("temp.xml", "w");
//curl_setopt($ch, CURLOPT_FILE, $fp);
//curl_setopt($ch, CURLOPT_HEADER, 0);
//curl_exec($ch);
//curl_close($ch);
//fclose($fp);
//$file = "temp.xml";
//$fp = fopen($file, "r");
//$data = fread($fp, 1000);
$data=@fread(fopen("http://www.websitepublisher.net/blog/feed/","r"),10000) or die("Cant open $url!");
// Get the file contents
$myar=getXmlData($data);
// What ever it may be, the argument to this
// function should be the XML document's content
// Now $myar holds the fully parsed XML contents.
// It may have a number of tags, like <TITLE> , <LINK> , <AUTHOR> , <SOMETHING> ... and so on
// With a simple loop, you can extract all the tags and their values neatly
// Remember, $i<= should be lesser than or equal to the number of values
// a tag has. If you give count($myar), it will only take the number of tags.
// See structure.txt for better understanding.
for($i=0;$i<=count($myar[TITLE]);$i++) {
// Here, we want to read the TITLE, DESCRIPTION, and LINK of the RSS feed.
// You can read the values of any tag like this.
// $myar[TITLE][$i], $myar[SOMETHING][$i], $myar[SOMETAG][$i].... and so on..
// Here it goes
$title=$myar[TITLE][$i+1];
$link=$myar[LINK][$i+1];
if($title) {
if ($i>=0 and $i<6) {
echo "<li><a href=\"".$link."\">".$title."</a></li>";
}
}
}
//#####################################################################
// This is the function. It returns the array of the parsed XML data
function getXmlData($xml_doc) {
//echo "xml_doc is ";
//echo $xml_doc;
$n=0; // Counter used for arraying the XML data
$ar=array(); // The main array for storing parsed xml using xml_parse_into_struct()
// Parse the XML document
$parser = xml_parser_create();
//$simple = "<para><note>simple note</note></para>";
$simple=$xml_doc;
//echo $simple;
xml_parse_into_struct($parser,$simple,$vals,$index);
// or die(xml_error_string(xml_get_error_code($parser)));
xml_parser_free($parser);
$ttags=array(); // Temporary arry for storing tag names
// The main part. This is MY CREATION
// and this piece of code makes this script simple :)
// This is the "MAGIC LOOP" !! :)
for($n=0;$n<=count($vals)-1;$n++) {
if(trim($vals[$n][value])) {
$ar[$vals[$n][tag]][count($ar[$vals[$n][tag]])]=$vals[$n][value];
$ttags[$vals[$n][tag]]=$vals[$n][tag];
}
}
// Array for storing all the tag names
// This array will hold all the Tag names found in the XML document
// eg: ("TITLE","LINK","AUTHOR","DOMAIN")..
// Use this if you need it.
$tags=array();
// Extract and save the tag names to the array
foreach($ttags as $tagi) { array_push($tags,$tagi); }
return $ar;
}
?>
...haha, you have the same script.
So, that is exactly what I use on this site, and it works. If you change the URLs you should be fine. Or maybe your webserver has an odd setting that is breaking it.
That script is way bad PHP.
The error message that its giving you is that your XML is bad. My guess is that your feed is too big for the simple fread function the way its used in that script. Hence, "unclosed tokens" because its only reading the first part of the feed.
You really should use SimplePie.
If thats the only bug in that script, I'd be surprised.
Thanks for your reply, Chris.
I guess I made some progress...
I copied the script that Chris posted and changed two URLs. Now the script looks like this:
I used another name and uploaded it here:PHP Code:
<?php
/*##############################################
RSS parser written for bMachine feed.
This script can be used to read ANY kind of RSS feeds from anywhere!
*--------------------------------------------*
Written by Kailash Nadh,
http://bnsoft.net , kailash@bnsoft.net
Author of bMachine, http://boastology.com
I wrote this script on the 1st day I studied
XML by running through the documentation at www.php.net ;)
*--------------------------------------------*
WARNING!: This script is Heavily commented! :)
This is how the script works.
> Reads the XML file
> Parses it into an array using xml_parse_into_struct()
> Converts that array into a more sensible, easily usable array
[ See the structure.txt file to get an idea of the array structure ]
> Finally, Display the data in anyway you want!
This script demonstrates the use of simple logic
to do Complex XML/RSS parsing functions
This script can be easily developed into a powerful application.
##############################################*/
global $data;
// Enter the url to an RSS feed
$url="http://feeds.feedburner.com/cardshark/";
//$file = $url;
//$ch = curl_init($file);
//$fp = @fopen("temp.xml", "w");
//curl_setopt($ch, CURLOPT_FILE, $fp);
//curl_setopt($ch, CURLOPT_HEADER, 0);
//curl_exec($ch);
//curl_close($ch);
//fclose($fp);
//$file = "temp.xml";
//$fp = fopen($file, "r");
//$data = fread($fp, 1000);
$data=@fread(fopen("http://feeds.feedburner.com/cardshark/","r"),10000) or die("Cant open $url!");
// Get the file contents
$myar=getXmlData($data);
// What ever it may be, the argument to this
// function should be the XML document's content
// Now $myar holds the fully parsed XML contents.
// It may have a number of tags, like <TITLE> , <LINK> , <AUTHOR> , <SOMETHING> ... and so on
// With a simple loop, you can extract all the tags and their values neatly
// Remember, $i<= should be lesser than or equal to the number of values
// a tag has. If you give count($myar), it will only take the number of tags.
// See structure.txt for better understanding.
for($i=0;$i<=count($myar[TITLE]);$i++) {
// Here, we want to read the TITLE, DESCRIPTION, and LINK of the RSS feed.
// You can read the values of any tag like this.
// $myar[TITLE][$i], $myar[SOMETHING][$i], $myar[SOMETAG][$i].... and so on..
// Here it goes
$title=$myar[TITLE][$i+1];
$link=$myar[LINK][$i+1];
if($title) {
if ($i>=0 and $i<6) {
echo "<li><a href=\"".$link."\">".$title."</a></li>";
}
}
}
//#####################################################################
// This is the function. It returns the array of the parsed XML data
function getXmlData($xml_doc) {
//echo "xml_doc is ";
//echo $xml_doc;
$n=0; // Counter used for arraying the XML data
$ar=array(); // The main array for storing parsed xml using xml_parse_into_struct()
// Parse the XML document
$parser = xml_parser_create();
//$simple = "<para><note>simple note</note></para>";
$simple=$xml_doc;
//echo $simple;
xml_parse_into_struct($parser,$simple,$vals,$index);
// or die(xml_error_string(xml_get_error_code($parser)));
xml_parser_free($parser);
$ttags=array(); // Temporary arry for storing tag names
// The main part. This is MY CREATION
// and this piece of code makes this script simple :)
// This is the "MAGIC LOOP" !! :)
for($n=0;$n<=count($vals)-1;$n++) {
if(trim($vals[$n][value])) {
$ar[$vals[$n][tag]][count($ar[$vals[$n][tag]])]=$vals[$n][value];
$ttags[$vals[$n][tag]]=$vals[$n][tag];
}
}
// Array for storing all the tag names
// This array will hold all the Tag names found in the XML document
// eg: ("TITLE","LINK","AUTHOR","DOMAIN")..
// Use this if you need it.
$tags=array();
// Extract and save the tag names to the array
foreach($ttags as $tagi) { array_push($tags,$tagi); }
return $ar;
}
?>
http://cardshark.us/scripts/rss_blog.php
Now at least I do get a result, but the script only returns my site's title linked to my site's URL (not the blog URL).
My feed URL is this:
http://feeds.feedburner.com/cardshark
I guess this is progress but now I'm kind of stuck again (I did try a few different things, though).
If you follow all the rules, you miss all the fun.
Sites: Bustout Dealer CASINOVILLE comics Playing Cards Sharps & Flats CARDSHARK Online CARDSHARK Online Blog Cardshark.TV NCIG The Mott Street Poker Club
Selkirk,
I just visited the SimplePie page again.
My problem is that I am a bit behind on all the terminology and can't figure out where to start looking for a solution on that page.
All I want to do is have 5 last titles on my blog to show up somewhere on my existing home page, which is a static HTML page. I think that I should just be able to add one tag to my HTML and a PHP script. But I just can't figure this out.
I don't know how much work it is at your end, but if you could just post a script I can copy and paste that would be great.
If you follow all the rules, you miss all the fun.
Sites: Bustout Dealer CASINOVILLE comics Playing Cards Sharps & Flats CARDSHARK Online CARDSHARK Online Blog Cardshark.TV NCIG The Mott Street Poker Club
I tried your url in my version of the script - same one Chris posted - and got similar results to you, so we know it can work. What you need to do is select the headings that the script is pulling from the feed.
that is this bit here (from Chris's script as that is working for you:
This is selecting the title and the link, which is exactly what you are getting.PHP Code:
$title=$myar[TITLE][$i+1];
$link=$myar[LINK][$i+1];
try including:
and then add below the echo statement underneath:PHP Code:
$description=$myar[DESCRIPTION][$i+1];
If you look at the source of the feed, ie direct at http://feeds.feedburner.com/cardshark you should see the other fields you can get from the feed.PHP Code:
echo $description;
Bookmarks