6

自分でやったこともないし、フィードを購読したこともありませんが、作成する必要があるようで、疑問に思っています。私には明らかな唯一の方法は、システムが新しい項目 (ブログ投稿、ニュース項目など) で更新されたときに、新しい要素を rss ファイルに書き込む必要があるということです。または、システムの更新を 1 日に数回チェックし、rss ファイルに書き込むスクリプトを用意することもできます。おそらくもっと良い方法があります。

また、新しい要素が追加されたときに古い要素を削除する必要がありますか?

編集:言及する必要がありましたが、私は PHP で作業しており、具体的には CodeIgniter を使用して mySQL データベースを使用しています。

4

8 に答える 8

6

PHP の場合、feedcreator http://feedcreator.org/を使用します。

<?php define ('CONFIG_SYSTEM_URL','http://www.domain.tld/');

require_once('feedcreator/feedcreator.class.php');

$feedformat='RSS2.0';

header('Content-type: application/xml');

$rss = new UniversalFeedCreator();
$rss->useCached();
$rss->title = "Item List";
$rss->cssStyleSheet='';
$rss->description = 'this feed';
$rss->link = CONFIG_SYSTEM_URL;
$rss->syndicationURL = CONFIG_SYSTEM_URL.'feed.php';


$articles=new itemList();  // list of stuff
foreach ($articles as $i) {   
    $item = new FeedItem();
    $item->title = sprintf('%s',$i->title);
    $item->link = CONFIG_SYSTEM_URL.'item.php?id='.$i->dbId;
    $item->description = $i->Subject;   
    $item->date = $i->ModifyDate;   
    $item->source = CONFIG_SYSTEM_URL;   
    $item->author = $i->User;
    $rss->addItem($item);
}

print $rss->createFeed($feedformat);
于 2008-11-03T05:28:21.217 に答える
4

An RSS Feed is just an XML Document that conforms to a specific schema.

Have a look here

What language are you working in? You can easily script the xml output based on some content in your application. You don't need to explicitly save the file to the file system. It can just be created on the fly

于 2008-11-02T20:57:47.923 に答える
3

I'd say the answer is having an RSS feed be nothing more than another view of your data. This means that your rss feed is simply an xml representation of the data in your database. Readers will then be able to hit that specific url and get back the current information in your application.

于 2008-11-02T20:56:45.740 に答える
2

Magpie RSSから良い結果が得られました。含まれているキャッシュを設定すると、クエリを記述してデータを取得し、その結果を Magpie RSS に送信して更新頻度を処理するだけです。

サーバーの負荷が特に重い場合を除き、RSS ファイルを作成することはありません。必要なのは、更新されたものに対する 1 つのクエリ (または配列に追加される一連のクエリ) だけです。日付でソートされ、X で制限されるようにクエリを作成すると、「古いものの削除」について心配する必要もありません。

于 2008-11-02T21:21:13.460 に答える
0

これにアプローチする方法は2つあります。1つは、要求に応じてRSSドキュメントを動的に作成することです。2つ目は、関連する変更が発生したときに静的ファイルに書き込むことです。後者の方が高速ですが、1つだけではなく、多くの場所でフィードを更新するための呼び出しが必要です。

どちらの方法でも、変更のみでドキュメントを編集できますが、最新(10〜50)のアイテムで毎回ドキュメント全体を書き直す方がはるかに簡単です。

于 2008-11-02T22:00:55.720 に答える
0

HTML に既に存在する要素のフィードを生成する場合、1 つのオプションは、hAtom ( http://microformats.org/wiki/hAtom ) を使用するように HTML マークアップを変更し、hAtom->Atom を介してフィード リーダーをポイントすることです。または hAtom->RSS プロキシ。

于 2008-11-04T09:59:02.760 に答える
0

RSS フィードは、特定の方法でフォーマットされ、Web ページからリンクされた単なる XML ドキュメントです。

このページ ( http://cyber.law.harvard.edu/rss/rss.html ) をご覧ください。RSS 仕様の詳細が記載されており、RSS ファイルの例が示され、RSS ファイルへのリンク方法が示されています。サイト。

どのようにドキュメントを作成するかはあなた次第です。テキスト エディターで手動で記述したり、言語固有の XML オブジェクトを使用したり、ASPX/PHP/その他のページにアクセスして RSS ドキュメントと共に正しいコンテンツ タイプ ヘッダーを送信したりできます。

ここまでくれば、それほど難しいことではありません。幸運を!

于 2008-11-02T21:12:44.197 に答える
0

これは、ローカルホストの開発サイトのライブ ブックマークとして使用する単純な ASP.NET 2 ベースの RSS フィードです。始めるのに役立つかもしれません:

<%@ Page Language="C#" EnableViewState="false" %>
<%@ OutputCache Duration="300" VaryByParam="none" %>

<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.DirectoryServices" %>

<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{
    System.Collections.Specialized.StringCollection HideSites = new StringCollection();
    System.Collections.Generic.List<string> Sites = new System.Collections.Generic.List<string>();

    HideSites.Add(@"IISHelp");
    HideSites.Add(@"MSMQ");
    HideSites.Add(@"Printers");

    DirectoryEntry entry = new DirectoryEntry("IIS://LocalHost/W3SVC/1/ROOT");
    foreach (DirectoryEntry site in entry.Children)
    {
        if (site.SchemaClassName == "IIsWebVirtualDir" && !HideSites.Contains(site.Name))
        {
            Sites.Add(site.Name);
        }
    }

    Sites.Sort();

    Response.Clear();
    Response.ContentType = "text/xml";
    XmlTextWriter RSS = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
    RSS.WriteStartDocument();
    RSS.WriteStartElement("rss");
    RSS.WriteAttributeString("version","2.0");
    RSS.WriteStartElement("channel");
    RSS.WriteElementString("title", "Localhost Websites");
    RSS.WriteElementString("link","http://localhost/sitelist.aspx");
    RSS.WriteElementString("description","localhost websites");

    foreach (string s in Sites)
    {
        RSS.WriteStartElement("item");
        RSS.WriteElementString("title", s);
        RSS.WriteElementString("link", "http://localhost/" + s);
        RSS.WriteEndElement();
    }

    RSS.WriteEndElement();
    RSS.WriteEndElement();
    RSS.WriteEndDocument();
    RSS.Flush();
    RSS.Close();
    Response.End();
}

</script>
于 2008-11-02T21:00:41.957 に答える