简体   繁体   English

如何使用XML和Javascript / Jquery从Twitter检索用户推文?

[英]How to Retrieve User Tweets from Twitter Using XML and Javascript/Jquery?

I am trying to retrived data from Twitter XML URL. 我正在尝试从Twitter XML URL检索数据。 here i wrote the code for it. 在这里,我为此编写了代码。 but it is not working. 但它不起作用。 could you tell me how to retrive Tweets and user name from the URL using XML and AJAX 您能否告诉我如何使用XML和AJAX从URL中检索推文和用户名

<script type="text/javascript">
$.ajax(
{  
    type: "POST",  
    url: "https://api.twitter.com/1/statuses/user_timeline.xml?screen_name=rushijogle",  
    data: "whatever",
    dataType: "xml",
    async: false,
    success: function(xml){

                var xmlDoc;

                if (window.DOMParser) {
                    parser = new DOMParser();
                    xmlDoc = parser.parseFromString(xml, "text/xml");
                }
                else // Internet Explorer
                {
                    xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
                    xmlDoc.async = "false";
                    xmlDoc.loadXML(xml);
                }

                var $response = $(xmlDoc);

             var data = $response.find("favorited").text()

        alert(data);
    }
});
</script>

Demo Link :- http://jsfiddle.net/be9y6/ 演示链接: -http : //jsfiddle.net/be9y6/

Thanx in Advance !! 提前感谢!

Twitter does not support XML anymore . Twitter 不再支持XML Also, it is uncler to me the reason why you're using POST , if that's a GET - but it might be that I am not acquainted with the demo you're trying to use as source. 此外,它是uncler给我,为什么你使用的原因POST ,如果这是一个GET -但它可能是我不跟你想作为源使用演示熟悉。 Anyhow, if you're trying to post a favourite (it's what I see from your code), you should switch to json and their API 1.1 protocols. 无论如何,如果您要发布收藏夹(这是我从代码中看到的内容),则应切换到json及其API 1.1协议。 They don't support XML I hope this helps. 他们不支持XML,希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM