嗨,我是Twitpic API的新手。我想要调用TwitPic API
http://api.twitpic.com/2/tags/show.xml?tag=“+搜索+ "&page=1”
我想用AJAX来做这件事,我现在的代码如下:
<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如下所示:
<body>
<input id="btnGetData" type="button" value="Twitter Get Tweets" />
<div id="tweets">
</div>
我没有收到任何错误,但是对此API的调用没有发生。我想解析从这个API返回的XML。如果你能为我提供解析Twitpic API XML的演示代码,这将是非常有帮助的。
提前感谢;Abhishek A. Sharma
发布于 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/
https://stackoverflow.com/questions/15628728
复制相似问题