Jump to content
Sign in to follow this  
urbancubed

RSS contribution

Recommended Posts

Hello

 

I have checked with my hosts & inputted the correct database details, so getting rid of my last error, but I am still getting the following error:

 

Only one top level element is allowed in an XML document.

Line: 2 Character: 2

 

<b>Parse error</b>: syntax error, unexpected T_STRING in <b>/home/xxxxxx/public_html/xxxxxx/rss.php</b> on line <b>15</b><br />

 

line 15 is: } else {

 

// Si la langue n'est pas spécifiée
if ($HTTP_GET_VARS['language'] == '') {
 $lang_query = tep_db_query('select languages_id, code from ' . TABLE_LANGUAGES . ' where directory = \'' . $language . '\'');
} else {
 $cur_language = tep_db_output($HTTP_GET_VARS['language']);
 $lang_query = tep_db_query('select languages_id, code from ' . TABLE_LANGUAGES . ' where code = \'' . $cur_language . '\'');
}

I have downloaded the file zip again & re uploaded to the root but still I cannot get this error to go away & a working rss to appear.

 

Pleeeeeease could someone give me an answer because I do not have a clue.

 

Thank you

Julie

Share this post


Link to post
Share on other sites

Hi

 

The RSS Feed is a verry fine script. I want to use it, to get my orders about rss feed. So i can check the orders simply from every computer, PDA and also from my Satellite Receiver. Any ideas how i can configure the script to get orders ?

 

Best regards

alocacoc

Share this post


Link to post
Share on other sites
Hi,

 

I just downloaded this tonight. My feed failed validation too :(

 

To answer your first question, your feed looks normal. That's how they look, nothing fancy.

 

I've been reading up on the error I got from the validator. Same as yours, re. the <image> tags.

 

Everything I know about RSS I learned tonight :blink: but basically, the documentation says that <image> is not a suitable "child" element of <item>

 

I took their word for it and made a change to the rss.php file

 

Near the bottom of the file, about line 168 I changed this

 

 if ($image != '') {
echo '  <image>' . "\n";
echo '	<url>' . $image_url . '</url>' . "\n";
echo '	<title>' . $name . '</title>' . "\n";
echo '	<link>' . $weblink . '</link>' . "\n";
echo '  </image>' . "\n";
 }

 

to this

 

/*  if ($image != '') {
echo '  <image>' . "\n";
echo '	<url>' . $image_url . '</url>' . "\n";
echo '	<title>' . $name . '</title>' . "\n";
echo '	<link>' . $weblink . '</link>' . "\n";
echo '  </image>' . "\n";
 }*/

 

to eliminate the problem.

 

Now I've been validated :lol:

 

Like I said, I don't know much about RSS but that fixed it for me.

Hi

 

I have finally sorted this! :D I do have three problems though.

 

1) I can't read the above code or understand what it means, but when I tried to validate I too had the <image> error. Do I amend the code as above on line 168-173 on /rss.php

 

2) My links are showing the oscsid & although it has been mentioned in this thread, I can't see an answer to it? Any suggestions? Is an issue or not? Maybe it is customer related & so different for everyone...& maybe not :blink:

 

3) In admin/configuration/maximum values/search results I already had it set for 20. On first subscribing to my feed I saw 20 new products. Then when I refreshed I saw 40/40 & the first 20 were repeated again. I have tried to refresh again but I don't get 60/60 etc. Again it has been mensioned but I can't see the answer to resolve it? What do I do about this one?

 

Thank you for any help with the above. :D

 

Julie

Share this post


Link to post
Share on other sites
Hi

 

I have finally sorted this! :D I do have three problems though.

 

1) I can't read the above code or understand what it means, but when I tried to validate I too had the <image> error. Do I amend the code as above on line 168-173 on /rss.php

 

2) My links are showing the oscsid & although it has been mentioned in this thread, I can't see an answer to it? Any suggestions? Is an issue or not? Maybe it is customer related & so different for everyone...& maybe not :blink:

 

3) In admin/configuration/maximum values/search results I already had it set for 20. On first subscribing to my feed I saw 20 new products. Then when I refreshed I saw 40/40 & the first 20 were repeated again. I have tried to refresh again but I don't get 60/60 etc. Again it has been mensioned but I can't see the answer to resolve it? What do I do about this one?

 

Thank you for any help with the above. :D

 

Julie

 

:D :D Number 1 sorted & I too am validated! :lol:

 

Still don't know what to do about number 2 & 3 :huh:

 

Any suggestions please? :-"

 

Thanks

Julie

Share this post


Link to post
Share on other sites

1) I can't read the above code or understand what it means, but when I tried to validate I too had the <image> error. Do I amend the code as above on line 168-173 on /rss.php

 

I beleive that will virtually remove the image from the feed, which is one way to get it to validate.

 

2) My links are showing the oscsid & although it has been mentioned in this thread, I can't see an answer to it? Any suggestions? Is an issue or not? Maybe it is customer related & so different for everyone...& maybe not blink.gif

 

Go into your admin/configuration.php. In the box on the left, there should be a link called sessions. Click that. At the next page, make sure where it says, Prevent Spider Sessions is set to True. YOu might also want to check the contributions area to see that you have an updated spiders.txt.

 

3) In admin/configuration/maximum values/search results I already had it set for 20. On first subscribing to my feed I saw 20 new products. Then when I refreshed I saw 40/40 & the first 20 were repeated again. I have tried to refresh again but I don't get 60/60 etc. Again it has been mensioned but I can't see the answer to resolve it? What do I do about this one?

 

I haven't tested this, but saw it elsewhere in my search. In rss.php, about line 89 Find:

 

// Create SQL statement
$category = $HTTP_GET_VARS['cPath'];
if ($category != '') {
 // Check to see if we are in a subcategory
 if (strrpos($category, '_') > 0) {
$category = substr($category, strrpos($category, '_') + 1, strlen($category));
 }
 $sql = 'SELECT p.products_id, products_model, products_image, products_price, products_date_added, products_tax_class_id FROM products p, products_to_categories pc WHERE p.products_id = pc.products_id AND pc.categories_id = \'' . $category . '\' AND products_status=1 ORDER BY products_id DESC LIMIT ' . MAX_DISPLAY_SEARCH_RESULTS;
} else {
 $sql = 'SELECT products_id, products_model, products_image, products_price,  products_date_added, products_tax_class_id FROM products WHERE products_status=1 ORDER BY products_id DESC LIMIT ' . MAX_DISPLAY_SEARCH_RESULTS;
}

 

Where it says MAX_DISPLAY_SEARCH_RESULTS change that to the number of items in your stock. That should bring up everything.

 

I REPEAT: I am merely recyling someone else's suggestion. I have no idea if it will actually work, but from what little I know of mySQL, I think it might work.

Share this post


Link to post
Share on other sites

Hello, I've searched the forums and could not find an answer to my problem, though a few other people seemed to have the same issue. So I'm posting to this lonely support forum again.

 

I have installed this contribution. It looked to be simple. I'm pretty good at following instructions and have installed others with no problem. Doesn't mean I haven't overlooked something, though.

 

I've made sure the white spaces were removed at the top and bottom of the file.

 

My Errors:

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /path/to/my/file/rss.php:1) in /path/to/my/file/includes/functions/sessions.php on line 67

Warning: Cannot modify header information - headers already sent by (output started at /path/to/my/file/rss.php:1) in /path/to/my/file/rss.php on line 73

 

I've gone to my includes/functions/sessions.php

LINE 66 & 67 are:

 

function tep_session_start() {
return session_start();

 

So, that doesn't seem to be a problem.

Then I check my rss.php file.

 

LINE 73 through 76 states:

Header('Content-Type: application/xml');
echo '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
echo '<?xml-stylesheet href="http://www.w3.org/2000/08/w3c-synd/style.css" type="text/css"?>' . "\n";
echo '<!-- RSS for ' . $store_name . ', generated on ' . date(r) . ' -->' . "\n";

 

I think that is telling me the same thing as the warning. The information was already sent and can't be modified.

 

OK, fair enough. So how do I fix this?

 

rss.php doesn't seem to have the <head> information in it. LINE 73 is about as close to a header as I can find.

If I remove the following code:

 

// Début de l'envoi des données
Header('Content-Type: application/xml');
echo '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
echo '<?xml-stylesheet href="http://www.w3.org/2000/08/w3c-synd/style.css" type="text/css"?>' . "\n";
echo '<!-- RSS for ' . $store_name . ', generated on ' . date(r) . ' -->' . "\n";

 

Then, even by clearing the cache and closing/reopening my browser, I STILL get the error:

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /path/to/my/file/rss.php:1) in /path/to/my/file/includes/functions/sessions.php on line 67

 

Is there a solution? Is anybody actually using this contribution successfully?

Share this post


Link to post
Share on other sites

I've searched "headers +already +sent".

 

All I can find out is that the rss.php file is sending headers when the include/header.php has already sent headers.

 

Is there a way to fix this this problem?

Share this post


Link to post
Share on other sites

OK, I fibbed. This is just bugging me. Someone said they didn't have my error until they changed something (versions?) that had different character encoding.

 

So I'm using the version that has charset of utf-8. And I'm wondering if that is what is clashing with my headers?

I tried a very old version of a different RSS feed and it worked fine with no header problems.

It didn't seem to support listing the products, so I can't use it, but it had the ISO-8859-1 charset that is specified in my html parameters in the header.

 

Here's what I found about character encodings:

 

"It is good practice to use the same encoding at all stages in document production, from text editing to display in a Web browser."

 

I'm too tired to try to find an older version and update it to have the features I want, so I'll try again later.

Good night.

Share this post


Link to post
Share on other sites

I'm curious. Can some one please explain to me why the latest RSS contribution has utf8_encode ? Isn't that a subset of ISO-8859-1? So what's the benefit? Seems like this RSS contribution is strictly for European sites?

Share this post


Link to post
Share on other sites

Well, here's what I've discovered so far.

 

My DB uses utf8 encoding.

 

The website HTTP header uses ISO-8859-1.

 

If I use an old version of rss.php, I can get the RSS feed to work BUT, my database is full of "&" and the feed throws an error everytime it reaches one. Since it's doubtful that anyone uses R and B for R&B music, I'm pretty much scroot.

 

I will need to find a way to make the utf8 encoding work with the rss.php feed without attempting to resend headers.

 

JULIE: Thank you for your response. You are apparently using an older version of rss.php. Here's a possible solution for stopping the duplicates.

 

In rss.php FIND:

 

<?php
// Create SQL statement
if ($HTTP_GET_VARS['cPath'] != "") {
 $sql = "SELECT p.products_id, products_model, products_image, products_price, products_tax_class_id FROM products p, products_to_categories pc WHERE p.products_id = pc.products_id AND pc.categories_id = '" . $HTTP_GET_VARS['cPath'] . "' AND products_status=1 ORDER BY products_id DESC LIMIT " . MAX_DISPLAY_SEARCH_RESULTS;
} else {
 $sql = "SELECT products_id, products_model, products_image, products_price,  products_tax_class_id FROM products WHERE products_status=1 ORDER BY products_id DESC LIMIT " . MAX_DISPLAY_SEARCH_RESULTS;
}

 

 

REPLACE WITH:

 

// Create SQL statement
if ($HTTP_GET_VARS['cPath'] != "") {
 $sql = "SELECT p.products_id, products_model, products_image, products_price, products_date_added, products_tax_class_id FROM products p, products_to_categories pc WHERE p.products_id = pc.products_id AND pc.categories_id = '" . $HTTP_GET_VARS['cPath'] . "' AND products_status=1 ORDER BY products_id DESC LIMIT " . MAX_DISPLAY_SEARCH_RESULTS;
} else {
 $sql = "SELECT products_id, products_model, products_image, products_price,  products_date_added, products_tax_class_id FROM products WHERE products_status=1 ORDER BY products_id DESC LIMIT " . MAX_DISPLAY_SEARCH_RESULTS;
}

 

FIND:

 

$price = $row["products_price"];

 

ADD UNDER IT

 

$added = date(r,strtotime($row['products_date_added']));

 

FIND:

 

echo "<item>
 <title>" . $name . "</title>
 <link>" . $link . "</link>
 <description>" . $desc . "</description>
 <price>" . $price . "</price>\n";

 

REPLACE WITH:

 

echo "<item>
  <title>" . $name . "</title>
  <link>" . $link . "</link>
  <description>" . $desc . "</description>
  <price>" . $price . "</price>
<pubDate>' . $added . '</pubDate>' \n";

 

That should take care of your duplication problem.

Share this post


Link to post
Share on other sites

I did a bit of research on utf-8 encoding. I must say I have been unable to get an RSS feed to validate without using it. I think this is do do with all the illegal characters like single quotes and accents that don't get stripped out of the output by other php functions. On the other hand php doesn't handle utf-8 all that well because it produces multibyte characters and some of the built-in string functions are not multi-byte safe. Also, as you mention, the headers are then probably not consistent withe the content. I'm not sure what you mean about European only though. I thought it handled most languages.

 

Well I only did some research. I didn't manage to solve the issue!

Share this post


Link to post
Share on other sites

I FINALLY can end this monologue. I wish someone would have jumped in with words of advice.

 

I now have my rss feed working properly AND it validates AND it shows all current products in the db AND it doesn't duplicate the items, etc. Want to know how I did it all?

 

Visit http://www.oscommerce.com/community/contributions,1513 and see the new contribution.

Share this post


Link to post
Share on other sites

Hey Radders! I didn't see your post. Thank you for your help in researching.

 

I had added utf-8 encoding to the new contribution. I kind of figured out it was important when my data was causing the errors in the feed without utf-8 encoding.

Share this post


Link to post
Share on other sites
JULIE: Thank you for your response. You are apparently using an older version of rss.php. Here's a possible solution for stopping the duplicates.

 

In rss.php FIND:

 

<?php
// Create SQL statement
if ($HTTP_GET_VARS['cPath'] != "") {
 $sql = "SELECT p.products_id, products_model, products_image, products_price, products_tax_class_id FROM products p, products_to_categories pc WHERE p.products_id = pc.products_id AND pc.categories_id = '" . $HTTP_GET_VARS['cPath'] . "' AND products_status=1 ORDER BY products_id DESC LIMIT " . MAX_DISPLAY_SEARCH_RESULTS;
} else {
 $sql = "SELECT products_id, products_model, products_image, products_price,  products_tax_class_id FROM products WHERE products_status=1 ORDER BY products_id DESC LIMIT " . MAX_DISPLAY_SEARCH_RESULTS;
}

REPLACE WITH:

 

// Create SQL statement
if ($HTTP_GET_VARS['cPath'] != "") {
 $sql = "SELECT p.products_id, products_model, products_image, products_price, products_date_added, products_tax_class_id FROM products p, products_to_categories pc WHERE p.products_id = pc.products_id AND pc.categories_id = '" . $HTTP_GET_VARS['cPath'] . "' AND products_status=1 ORDER BY products_id DESC LIMIT " . MAX_DISPLAY_SEARCH_RESULTS;
} else {
 $sql = "SELECT products_id, products_model, products_image, products_price,  products_date_added, products_tax_class_id FROM products WHERE products_status=1 ORDER BY products_id DESC LIMIT " . MAX_DISPLAY_SEARCH_RESULTS;
}

 

FIND:

 

$price = $row["products_price"];

 

ADD UNDER IT

 

$added = date(r,strtotime($row['products_date_added']));

 

FIND:

 

echo "<item>
 <title>" . $name . "</title>
 <link>" . $link . "</link>
 <description>" . $desc . "</description>
 <price>" . $price . "</price>\n";

 

REPLACE WITH:

 

echo "<item>
  <title>" . $name . "</title>
  <link>" . $link . "</link>
  <description>" . $desc . "</description>
  <price>" . $price . "</price>
<pubDate>' . $added . '</pubDate>' \n";

 

That should take care of your duplication problem.

:thumbsup: :) :thumbsup: Thanks for taking the time to solve the unanswered problems. Much appreciated as I do not have the knowledge to make all but simple code changes.

 

Julie

Share this post


Link to post
Share on other sites

Any way to list all products added in the last 30 days? Also, would like to put the time in the actual time instead of 12:00.

 

Thanks.

Share this post


Link to post
Share on other sites
I've searched "headers +already +sent".

 

All I can find out is that the rss.php file is sending headers when the include/header.php has already sent headers.

 

Is there a way to fix this this problem?

 

Double check that there is not an extra empty line at the end of the file: a simple carriage return at the end may cause this.

Share this post


Link to post
Share on other sites
Double check that there is not an extra empty line at the end of the file: a simple carriage return at the end may cause this.

 

pixclinic, that was the very first thing I checked. It did not fix my original problem.

Share this post


Link to post
Share on other sites

Barry, you might want to check your db to see that when you added the products, you are adding the date to the db.

Both your issues should be solved with the any rss feed that has the date code in it IF your products have the date in the db.

 

If the dates are there, then I'm sorry. I don't know any other answer.

Share this post


Link to post
Share on other sites

Hi

 

I have just realised my feed is saying "Internet Explorer was unable to update this feed and will try again later." & showing very old products so this has been there for while! :blush: Just remembered I didn't get round to recoding as Lostndazed said for duplicates. :blush: :blush: I will do that tonight. :-"

 

Does anyone have an idea why my feed isn't updating please? It has validated.

 

Thanks

Julie

Share this post


Link to post
Share on other sites
JULIE: Thank you for your response. You are apparently using an older version of rss.php. Here's a possible solution for stopping the duplicates.

 

In rss.php FIND:

 

<?php
// Create SQL statement
if ($HTTP_GET_VARS['cPath'] != "") {
 $sql = "SELECT p.products_id, products_model, products_image, products_price, products_tax_class_id FROM products p, products_to_categories pc WHERE p.products_id = pc.products_id AND pc.categories_id = '" . $HTTP_GET_VARS['cPath'] . "' AND products_status=1 ORDER BY products_id DESC LIMIT " . MAX_DISPLAY_SEARCH_RESULTS;
} else {
 $sql = "SELECT products_id, products_model, products_image, products_price,  products_tax_class_id FROM products WHERE products_status=1 ORDER BY products_id DESC LIMIT " . MAX_DISPLAY_SEARCH_RESULTS;
}

 

I have this:

// Create SQL statement
$category = $HTTP_GET_VARS['cPath'];
if ($category != '') {
 // Check to see if we are in a subcategory
 if (strrpos($category, '_') > 0) {
$category = substr($category, strrpos($category, '_') + 1, strlen($category));
 }
 $sql = 'SELECT p.products_id, products_model, products_image, products_price, products_tax_class_id FROM products p, products_to_categories pc WHERE p.products_id = pc.products_id AND pc.categories_id = \'' . $category . '\' AND products_status=1 ORDER BY products_id DESC LIMIT ' . MAX_DISPLAY_SEARCH_RESULTS;
} else {
 $sql = 'SELECT products_id, products_model, products_image, products_price,  products_tax_class_id FROM products WHERE products_status=1 ORDER BY products_id DESC LIMIT ' . MAX_DISPLAY_SEARCH_RESULTS;
}

REPLACE WITH:

 

// Create SQL statement
if ($HTTP_GET_VARS['cPath'] != "") {
 $sql = "SELECT p.products_id, products_model, products_image, products_price, products_date_added, products_tax_class_id FROM products p, products_to_categories pc WHERE p.products_id = pc.products_id AND pc.categories_id = '" . $HTTP_GET_VARS['cPath'] . "' AND products_status=1 ORDER BY products_id DESC LIMIT " . MAX_DISPLAY_SEARCH_RESULTS;
} else {
 $sql = "SELECT products_id, products_model, products_image, products_price,  products_date_added, products_tax_class_id FROM products WHERE products_status=1 ORDER BY products_id DESC LIMIT " . MAX_DISPLAY_SEARCH_RESULTS;
}

 

FIND:

 

$price = $row["products_price"];

 

I have this:

  $price = $row['products_price'];

ADD UNDER IT

 

$added = date(r,strtotime($row['products_date_added']));

 

FIND:

 

echo "<item>
 <title>" . $name . "</title>
 <link>" . $link . "</link>
 <description>" . $desc . "</description>
 <price>" . $price . "</price>\n";

 

I have this:

  echo '<item>' . "\n";
 echo '  <title>' , $name , '</title>' . "\n";
 echo '  <link>' , $link , '</link>' . "\n";
 echo '  <description>' . "\n";
 echo $desc . "\n";
 echo '  </description>' . "\n";

REPLACE WITH:

 

echo "<item>
  <title>" . $name . "</title>
  <link>" . $link . "</link>
  <description>" . $desc . "</description>
  <price>" . $price . "</price>
<pubDate>' . $added . '</pubDate>' \n";

 

That should take care of your duplication problem.

Hi again

 

Finally got round to doing this & I have a few differences. I think the first two are similar, but the third one is quite a bit different.

 

Have I got the right bits? Alternatively do you have the correct version of the rss.php & I just need to amend my bits please?

:D

 

Thanks

Julie

Share this post


Link to post
Share on other sites

Duplicate items? Here's the solution:

 

First the cause:

 

Duplicate items within the RSS feed are caused due to the fact that the links within the feed contain a session ID (e.g. osCsid=some unique number). This means that each time the feed is reloaded by a feed reader, the links within the feed receive a new session ID. This causes a feed reader (like the feed reader function of IE 7) to "think": "Hey, those links are new. So, the items they are linking to must be new too. Let's add all the items as new / unread items. Oh, I'm so smart."

 

Wrong! The links aren't new, only the session ID numbers at the end of the links are "new".

 

Solution:

 

Get rid of those session IDs at the end of the links of your feed. Just follow the following steps:

 

Open rss.php and find:

 

$link = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $id);

 

Replace with:

 

$link = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $id, 'NONSSL', false);

 

'NONSSL' tells the tep_href_link function to build a non SSL link, leave the NON out if you prefer a SSL link. And false tells the tep_href_link function to leave the session ID out of the link that has to be build.

 

That's all folks!

Edited by Ralph2

Share this post


Link to post
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
Sign in to follow this  

×