我们正在创建一个像news feed这样的应用程序。如何从rss feed获取数据,我需要通过json提供webservice

We are creating an application like news feed.How to get data from rss feeds and i need to provide webservice through json.I am using php codeigniter as server side scripting.

How to get feeds from different sites and send json response dynamically.

There's quite a lot of rss feed jquery plugins out there. That could be a simple and fast to implement solution for a basic need.

For example see zrrsfeed (Check the examples).

That's just one rss plugins among many others.

An Alternative to jquery could be php CURL, and an example of printing out the feed onto the screen from curl could happen 1 of two ways, from an RSS source, or as an ATOM source, this of course depends on the source FEED.

More Information about Atom vs RSS can be found here: https://shafiq2410.wordpress.com/2012/08/05/rss-vs-atom-which-one-is-better/

An Example of integrating BOTH into 1 application could look like this

// RSS
function parseRSS($xml)
{
    echo "<strong>".$xml->channel->title."</strong><br />";
    $cnt = count($xml->channel->item);
    for($i=0; $i<$cnt; $i++)
    {
        $url    = $xml->channel->item[$i]->link;
        $title  = $xml->channel->item[$i]->title;
        $desc = $xml->channel->item[$i]->description;

        echo '<a href="'.$url.'">'.$title.'</a>'.$desc.'<br />';
    }
}

// Atom
function parseAtom($xml)
{
    echo "<strong>".$xml->author->name."</strong><br />";
    $cnt = count($xml->entry);
    for($i=0; $i<$cnt; $i++)
    {
        $urlAtt = $xml->entry->link[$i]->attributes();
        $url    = $urlAtt['href'];
        $title  = $xml->entry->title;
        $desc   = strip_tags($xml->entry->content);

        echo '<a href="'.$url.'">'.$title.'</a>'.$desc.'<br />';
    }
}

$ch = curl_init("http://domain.com/path/to/rss.xml");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);

$doc = new SimpleXmlElement($data, LIBXML_NOCDATA);
if(isset($doc->channel))
{
    // Parse as RSS
    parseRSS($doc);
}
if(isset($doc->entry))
{
    // Parse as ATOM
    parseAtom($doc);
}

Of course instead of echoing out the results, you could handle them however you needed at this point, being that i dont know your overall goal here, i wanted to at least point you in the CURL direction as an option.

I hope this helps get you started.