首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从TwitPic接口中获取xml

如何从TwitPic接口中获取xml
EN

Stack Overflow用户
提问于 2013-03-26 11:14:25
回答 1查看 77关注 0票数 0

嗨,我是Twitpic API的新手。我想要调用TwitPic API

http://api.twitpic.com/2/tags/show.xml?tag=“+搜索+ "&page=1”

我想用AJAX来做这件事,我现在的代码如下:

代码语言:javascript
复制
<script type="text/javascript">
    var searchq = 'first';
    $(document).ready(function () {
        $("#btnGetData").click(function () {
                $.ajax({
                type: "GET",
                /* define url of xml file to parse */
                url: "http://api.twitpic.com/2/tags/show.xml?tag=" + searchq + "&page=1",
                /* assign it a data type */
                dataType: "xml",
                /* state name of function to run if file is successfully parsed */
                success: parseXml
            });
        });
    });
    function parseXml(xml)
    /* this is where the xml file is parsed and converted into a HTML output */
    {

        //for each item node in the xml file
        $(xml).find("image").each(function () {
            //print the following html, inserting the relevant data within the nodes of item
            //this is the heading
            $("#tweets").append($(this).attr("id") + "<br />");
            $("#tweets").append($(this).attr("short_id") + "<br />");
            $("#tweets").append($(this).attr("type") + "<br />");
            $("#tweets").append($(this).attr("timestamp") + "<br />");

        });
        //end for each 
        //end function
    }

</script>

我的HTML如下所示:

代码语言:javascript
复制
<body>
<input id="btnGetData" type="button" value="Twitter Get Tweets" />
<div id="tweets">
</div>

我没有收到任何错误,但是对此API的调用没有发生。我想解析从这个API返回的XML。如果你能为我提供解析Twitpic API XML的演示代码,这将是非常有帮助的。

提前感谢;Abhishek A. Sharma

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-26 15:02:52

我也不太了解twit图片,但是下面的链接可以帮到你很多。

1) http://twitpic.com/photos/jQuery

2) http://pastebin.com/RubQg0Nu

3) http://blog.0100.tv/2009/05/using-twitter-and-twitpic-the-apis/

4) http://dev.twitpic.com/docs/2/tags_show/

5) http://dev.twitpic.com/docs/2/tags_create/

6) http://dev.twitpic.com/docs/2/faces_show/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15628728

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档