homepage Welcome to WebmasterWorld Guest from 54.196.198.213
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / RSS, ATOM, and Related Technologies
Forum Library, Charter, Moderators: bill & werty

RSS, ATOM, and Related Technologies Forum

    
How do I insert RSS feed content into php
I am really struggling to understand this process. Please help me!
revtim




msg:3679012
 8:49 pm on Jun 19, 2008 (gmt 0)

I have built a content site and want to add topical news feeds that relate to the specific topic of the various pages. For some reason, I am really having trouble understanding how to do this. I have added RSS code for a packaged news feed on the page already but I want to add one of my own if possible that is more targeted.

I have uploaded magpierss onto the site but all their instructions say is

At the top of your script add the following line:

require_once('magpierss/rss_fetch.inc');

Now you can use the fetch_rss() method:

$rss = fetch_rss($url);

This seems simple enough but it isn't if one doesn't understand what "script" they are referring to. I can copy and paste code in the proper place and I can edit it as instructed but here.. i am totally lost. I know they expect me to be smarter or more experienced than I am but try as I might, I have not found a tutorial that takes me from the level of understanding I am currently at through completion.

There are dozens of readers and they either are web based and don't offer any ability to alter the format or they are install ones that make my head hurt.

Please, can anyone walk me through the process of inserting a feed into my .php page? With the time I have spent trying to grasp this, I could have gone to med school and be completing my internship (well not quite that bad but you get the point).

Thanks

magpierss is installed at
mydomain/magpierss
web pages are installed at
mydomain/subjectpage.php

It is a linux shared server through <snip>

[edited by: bill at 1:12 am (utc) on June 20, 2008]
[edit reason] hosting specifics snipped [/edit]

 

bill




msg:3679149
 1:14 am on Jun 20, 2008 (gmt 0)

Welcome to WebmasterWorld revtim.

Have you read through our Short guide to include RSS on your website [webmasterworld.com] thread?

revtim




msg:3679681
 4:37 pm on Jun 20, 2008 (gmt 0)

I had not but just did. I followed each instruction carefully and double checked my work. When I got to step D

D. Putting it all together

Now browse to the URL /rssdemo/feed.php on your web server. The feed should be displayed with some red lines around each item.

This is what i get displayed in my browser

? /* The folder where this file is located. Change to whatever you need */ $mydir = "/rssdemo"; /* Include magpierss and Smarty library */ require_once($_SERVER["DOCUMENT_ROOT"].$mydir."/Smarty/libs/Smarty.class.php"); require_once($_SERVER["DOCUMENT_ROOT"].$mydir."/magpierss/rss_fetch.inc"); /* Create a template object for further use */ $tpl = new Smarty(); /* Set folders for Smarty object. This folders have to exist on your web server (Check A.3) */ $tpl->template_dir = $_SERVER["DOCUMENT_ROOT"].$mydir.'/templates/'; $tpl->compile_dir = $_SERVER["DOCUMENT_ROOT"].$mydir.'/templates_c/'; $tpl->config_dir = $_SERVER["DOCUMENT_ROOT"].$mydir.'/configs/'; $tpl->cache_dir = $_SERVER["DOCUMENT_ROOT"].$mydir.'/cache/'; /* The URL of the feed we want to include */ $url = "http://rss.news.yahoo.com/rss/world"; /* magpierss does all the work! */ $rss = fetch_rss($url); /* Uncomment the following line to see the object and array data returned. Good to see which other information has been processed by magpierss */ // echo "

"; print_r($rss); echo "

"; /* If the RSS could be parsed, add it to the template */ if ($rss) { /* Sends the feed title to the template engine */ $tpl->assign("feedtitle",$rss->channel["title"]); /* Sends the RSS items as an array */ $tpl->assign("items",$rss->items); } else { /* RSS problem? */ $tpl->assign("feedtitle","Problem with: $url"); } /* Fill the template file itemlist.html with the information and return it */ $feedhtml = $tpl->fetch($_SERVER["DOCUMENT_ROOT"].$mydir."/templates/itemlist.html"); /* Do with $feedhtml whatever you want */ echo $feedhtml; ?>

When I check the code in the feed.php file, there are a lot of brackets that are yellow and have this notation when you center your cursor over them.
"Tag is market invalid because it has an extra angle bracket"

I am using Expression Web FYI. Since the rest of the code does not have the usual colors associated with functioning code, I am going to assume that something is wrong with the code.
PS, I used notepad ++ to make the .php file.

So, perhaps if I knew what is wrong with this little bracket problem I might be able to get this working. Any ideas? I will PM you the URL because I don't know how you feel about posting URL's on your forum.

revtim




msg:3679731
 6:02 pm on Jun 20, 2008 (gmt 0)

ok.. found an error. working now.. thanks..

bill




msg:3680028
 4:41 am on Jun 21, 2008 (gmt 0)

What was the error you found, and how did you fix it?

revtim




msg:3681389
 12:49 pm on Jun 23, 2008 (gmt 0)

The first line of Php was

<?

When I copy/pasted the code onto my page, I missed the < of all things. That was all it took to mess it up and replacing it fixed it.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / RSS, ATOM, and Related Technologies
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved