Google Feed API JSON输出未显示最新记录

时间:2015-04-01 10:53:52

标签: json rss feed google-feed-api

我正在尝试使用Google Feed API加载Feed,但我无法获取最新记录。我试过以下:

<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
  <script type="text/javascript">
      $(function () {
          url = 'http://www.propertyguru.com.sg/news-rss/SG-PM';
          var randomNum = Math.floor((Math.random() * 10000) + 1);
          $.ajax({
              type: "GET",
              url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=20&callback=?&q=' + encodeURIComponent(url) + '&nocache=' + (new Date).getTime() + randomNum,
              dataType: 'json',
              historical: false,
              error: function () {
                  alert("Unable to load feed, Incorrect path or invalid feed");
              },
              success: function (data) {
                  alert(JSON.stringify(data, null, "\t"));
              }
          });
      });
  </script>

1 个答案:

答案 0 :(得分:0)

您错误地编码了q url查询参数,callback参数出现问题。请尝试使用此网址:

https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&q=http://www.propertyguru.com.sg/news-rss/SG-PM