我正在嘗試在我的Kohana應用程序中創建rss源。我在我的控制器中做到這一點:在Kohana3中更改內容類型標頭
public function action_rss()
{
$games = ORM::factory('game')
->order_by('name','ASC')
->find_all()
->as_array();
$view = View::factory('home/rss')
->bind('games', $games);
$this->request->$headers['Content-type'] = 'application/rss+xml; charset=UTF-8';
$this->request->response = $view;
}
它不起作用(當我刪除$標題行,它確實,但與HTML類型)。我如何發送rss + xml的響應?
謝謝。
根據規範,它是'Content-Type',而不是'Content-type'。 Nitpicking,我知道。 – Geert 2010-07-29 20:29:03
有一點值得注意的是Kohana 3有一個內置的RSS助手。 – alex 2010-07-30 00:21:45
用'Kohana :: $ charset'替換字符集也是一個好主意。你永遠不知道...:P – alex 2010-07-30 00:22:48