json
  • rss
  • feed
  • google-feed-api
  • 2015-04-01 86 views 1 likes 
    1

    我正尝试使用Google Feed API加载Feed,但我无法获取最新记录。下面我曾尝试:Google Feed API JSON输出不显示最新记录

    <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> 
    
    +0

    你试过把你的AJAX URL粘贴到浏览器中吗? – 2015-04-01 10:57:20

    +0

    使用一些REST客户端添加为Firefox和测试REST网址.... – 2015-04-01 11:00:44

    +0

    您的AJAX调用成功,但返回null。 – 2015-04-01 11:04:04

    回答

    0

    你被错误编码q网址查询参数,并有一个与callback参数有问题。试试这个URL代替:

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

    我还没有收到最新的记录 – 2015-04-01 11:28:11

    +0

    将上面的网址粘贴到浏览器中,告诉我你看到了什么。 – 2015-04-01 11:29:41

    +0

    我可以看到“2015年2月5日”的记录,并且网址有“2015年4月1日”的最新记录 – 2015-04-01 11:42:08

    相关问题