显示跨域订阅RSS在Word preSS网站 [英] Display Cross-domain feed RSS in Wordpress site

查看:108
本文介绍了显示跨域订阅RSS在Word preSS网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示跨域饲料,RSS(XML格式)在我的网站,但我得到一个错误,因为AJAX跨域调用是不允许的。有人告诉我有关JSON-P ...任何人都知道如何使用还是有一些很好的教程?

I need to display cross-domain feeds-rss (XML format)in my site, but i get a error because ajax cross-domain call are not allowed. I've been told about json-p...anyone knows how to use or have some good tutorial?

感谢

推荐答案

最简单的方法就是创建一个小部件字preSS或下载一些有点像你的要求。

the simplest way is just to create an widget for wordpress or download some kind of like your requirement.

由于 JSON-P ,如果你想从 JSON 负载数据格式> JSON 格式,那么给定的链接将帮助您:

Because json-p load data in JSON format if you want to get data from JSON format then the given link will help you :

的getJSON AJAX

也可以访问RSS提要的PHP一样给出的例子:

or you can access the rss feed with php like given example :

$xml = 'http://blog.webtech11.com/feed';
                $doc = new DOMDocument();
                $doc->load($xml);
                $item = $doc->getElementsByTagName('item');

                //$data = array();

                for($i=0; $i<=3; $i++){
                    $title = $item->item($i)->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
                    $link = $item->item($i)->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue;
                    echo '<a href="' . $link . '" target="_blank"><h2>' . $title . '</h2></a>';
                }

在这个例子中我获得最新的4博客文章。

in this example i access latest 4 blog entries..

希望这会帮助你。

这篇关于显示跨域订阅RSS在Word preSS网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆