Welcome Guest, Not a member yet? Register   Sign In
RSS Feed - Header Problem
#1

[eluser]Voovu[/eluser]
Hello,

i hope this forum is correct to post my problem.

i'm trying to build a rss feed and use this tutorial:
http://net.tutsplus.com/tutorials/php/bu...deigniter/

the problem is this:
Code:
header("Content-Type: application/rss+xml");
if i use that line i get error that header information is still set-up, that right but it is text/html ... i have also try such line like this:
Code:
$this->output->set_header("Content-Type: application/rss+xml");
but this also dont work ...

can someone help me with this issue?

regards
#2

[eluser]elambiguo[/eluser]
This is my controller....

Code:
class Feed extends Controller
{

    function Feed()
    {
        parent::Controller();
        $this->load->model('setup_model', '', TRUE);
        $this->load->helper('xml','html','url');
    }
    
    function index()
    {
        $data['encoding'] = 'utf-8';
        $data['feed_name'] = 'xxxxxxxx';
        $data['feed_url'] = site_url();
        $data['page_description'] = 'xxxxxxxxxxxxx';
        $data['page_language'] = 'es';
        $data['creator_email'] = 'xxxxxxx@xxxxxxx';
        $data['posts'] = $this->setup_model->getRecentPosts();    
        header("Content-Type: application/rss+xml");
        $this->load->view('rss', $data);
    }
}

And works perfectly....

And this......

Code:
<?php
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";

?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
    <atom:link href="&lt;?php echo site_url() . "feed/rss.xml" ?&gt;" rel="self" type="application/rss+xml"></atom:link>

Is part of the view code....


I hope this help....
#3

[eluser]attos[/eluser]
Try the following in your view:

Code:
echo '&lt;?xml version="1.0" encoding="utf-8" \x3F>'."\n";

Notice how the XML tag is closed (\x3F> versus ?&gtWink
#4

[eluser]Voovu[/eluser]
That also dont work ...

the problem is still the same the type of header will not change it's text/html ...
Code:
header("Content-Type: application/xhtml+xml");
header("Content-Type: application/rss+xml");
header("Content-Type: text/xml");

nothing work's, sometimes the page will show nothing and sometimes:
Quote:http://domain.com/feed What my site is about comes here en-en [email protected] Copyright 2009
i use exact script and db that shows in the tut, i also note that i must load the database etc ... what can i do ?
#5

[eluser]Voovu[/eluser]
well ok, now it works - thread can be closed - thanks!
#6

[eluser]elambiguo[/eluser]
[quote author="Voovu" date="1260302601"]well ok, now it works - thread can be closed - thanks![/quote]

Please... Post the solution (if it is posible)... useful for anyone that this thread reads.
#7

[eluser]Voovu[/eluser]
[quote author="elambiguo" date="1260370720"]
Please... Post the solution (if it is posible)... useful for anyone that this thread reads.[/quote]

ok sorry Smile

well i have done this:

Code:
header("Content-Type: text/xml");
and my biggest issue (or from the guide) is the end from the file so i have change it to:

Code:
/* End of file feed.php */
/* Location: ./system/application/controllers/feed.php */
instead of that:
Code:
?&gt;
#8

[eluser]elambiguo[/eluser]
Thanks.... sometimes the minor bug is a great solution.... XD
#9

[eluser]Unknown[/eluser]
I spent all day trying to figure out why my feed was not displaying properly. Then I read this thread.

THANKS

BTW, I had a "?&gt;" at the end of my controller file. Removed that and it works. Both "application/rss+xml" and "text/xml" content types work for me.




Theme © iAndrew 2016 - Forum software by © MyBB