{"id":245,"date":"2005-11-03T01:14:59","date_gmt":"2005-11-03T00:14:59","guid":{"rendered":"http:\/\/www.centralscrutinizer.it\/test\/"},"modified":"2005-11-07T05:36:57","modified_gmt":"2005-11-07T04:36:57","slug":"testajax","status":"publish","type":"page","link":"https:\/\/centralscrutinizer.it\/italiano\/testajax\/","title":{"rendered":"Test"},"content":{"rendered":"<p>Inspired by the swiss example, one week ago Luca Conti launched the proposal to create an  italian blogs ranking based on <a href=\"http:\/\/technorati.com\">Technorati<\/a>.<br \/>\nTo the point, searching for a simple way to made it, I found<br \/>\nand suggested <a href=\"http:\/\/www.kailashnadh.name\/ducksoup\/\"><strong>Duck Soup<\/strong><\/a>, a PHP library that allow simple utilization of all the infos served by  <a href=\"http:\/\/developers.technorati.com\/wiki\/TechnoratiApi\">Technorati&#8217;s APIs<\/a>. <\/p>\n<p>Using  its <a href=\"http:\/\/developers.technorati.com\/wiki\/BlogInfoQuery\">BlogInfoQuery<\/a> support, I create  an AJAX powered simple form that returns the data that Technorati links to a blog.<\/p>\n<p>Here&#8217;s the example: just enter the URL of your blog and click the button. <\/p>\n<div class=\"technogames\">\n<h3>Technorati&#8217;s Blog Info<\/h3>\n<p><script language=\"javascript\" type=\"text\/javascript\" src=\"http:\/\/www.centralscrutinizer.it\/test\/bloginfoajaxen.js\"><\/script><\/p>\n<form>\n  <input type=\"text\"  id=\"blog_url\"  value=\"http:\/\/\" \/><br \/>\n  <input type=\"button\" value=\"Get Info\" id=\"cercablog\" onclick=\"getInfo();\"\/><br \/>\n<\/form>\n<div id=\"loading\"><\/div>\n<div id=\"results\"><\/div>\n<\/div>\n<p>How it works?<br \/>\nThe PHP  below (called <strong>bloginfo.php<\/strong>) asks to <strong>duckSoup library<\/strong> to return an XML that contain the informations related to an URL passed by parameter <strong>blog&#95;url<\/strong>.<br \/>\nFor example, if I want to know the info corresponding to the URL <strong>http:\/\/www.vlog.it<\/strong> (<a href=\"http:\/\/www.vlog.it\">this blog<\/a>), I can made the call (an HTTP GET)  trought the URL <strong>http:\/\/bloginfo.php?blog_url=http:\/\/www.vlog.it<\/strong>:  the script will return an XML<br \/>\n with the tags <strong>&#60;name&#62;<\/strong>Vlog..it &#8211; videoblog gallery<strong>&#60;\/name&#62;<\/strong>, <strong>&#60;rank&#62;<\/strong>15680<strong>&#60;\/rank&#62; <\/strong>and <a href=\"http:\/\/developers.technorati.com\/wiki\/BlogInfoQuery\">so on<\/a>.<\/p>\n<div class=\"thecode\">\n&#60;?php header(&#8220;Content-type:text\/xml; charset=UTF-8&#8243;);<br \/>\n             echo &#8216;&#60;?xml version=&#8221;1.0&#8243; standalone=&#8221;yes&#8221;?&#62;&#8217;; ?&#62;<br \/>\n&#60;?php<br \/>\n&#32;&#32;include &#8220;duckSoup.php&#8221;;<br \/>\n&#32;\t\t$api = new duckSoup;<br \/> <br \/>\n&#32;\t\t$api-&#62;api_key = &#8221; &#8220;;\t<strong>\/\/ insert your API key<\/strong><br \/>\n&#32;\t\t$api-&#62;type = &#8216;bloginfo&#8217;;\t<strong>\/\/ select a Technorati API<\/strong> <br \/>\n&#32;\t\t$api-&#62;params = array(&#8216;url&#8217; =&#62; $_REQUEST[&#8216;blog_url&#8217;]);<br \/>\n&#32;\t\t$blog_url=$api-&#62;get_content();<br \/>\n               \techo &#8220;<br \/>\n\t\t&#60;root&#62;&#8221;;<br \/>\n\t\t               if(empty($blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;][&#8216;name&#8217;])){<br \/>\n\t\techo  &#8220;&#60;name&#62;not indexed&#60;\/name&#62;&#8221;;}<br \/>\n\t\telse{<br \/>\t<br \/>\n\t\techo &#8220;&#60;name&#62;{$blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;][&#8216;name&#8217;]}&#60;\/name&#62;&#8221;;<br \/>\n\t\t}<br \/>\n\t\tif(empty($blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;][&#8216;url&#8217;])){<br \/> <br \/>\n\t\techo  &#8220;&#60;url&#62;not indexed&#60;\/url&#62;&#8221;;}<br \/>\n\t\telse{<br \/>\n\t\techo &#8220;&#60;url&#62;{$blog_url[&#8216;result&#8217;][&#8216;url&#8217;]}&#60;\/url&#62;&#8221;;<br \/>\n\t\t}<br \/>\n\t\tif(empty($blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;]<br \/>[&#8216;inboundlinks&#8217;])){<br \/> <br \/>\n\t\techo  &#8220;&#60;inboundlinks&#62;not indexed&#60;\/inboundlinks&#62;&#8221;;}<br \/>\n\t\telse{<br \/>\n\t\techo <br \/>&#8220;&#60;inboundlinks&#62;{$blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;]<br \/>[&#8216;inboundlinks&#8217;]}&#60;\/inboundlinks&#62;&#8221;;<br \/>\n\t\t}<br \/>\n\t\tif(empty($blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;]<br \/>[&#8216;inboundblogs&#8217;])){<br \/>\n\t\techo  &#8220;&#60;inboundblogs&#62;not indexed&#60;\/inboundblogs&#62;&#8221;;}<br \/>\n\t\telse{<br \/>\n\t\techo<br \/>  &#8220;&#60;inboundblogs&#62;{$blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;]<br \/>[&#8216;inboundblogs&#8217;]}&#60;\/inboundblogs&#62;&#8221;;<br \/>\n\t\t}<br \/>\n\t\tif(empty($blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;][&#8216;rank&#8217;])){ <br \/>\n\t\techo  &#8220;&#60;rank&#62;not indexed&#60;\/rank&#62;&#8221;;}<br \/>\n\t\telse{<br \/>\n\t\techo &#8220;&#60;rank&#62;{$blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;][&#8216;rank&#8217;]}&#60;\/rank&#62;&#8221;;<br \/>\n\t\t}<br \/>\n\t\tif(empty($blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;]<br \/>[&#8216;rssurl&#8217;])){<br \/> <br \/>\n\t\techo  &#8220;&#60;rssurl&#62;url not indexed&#60;\/rssurl&#62;&#8221;;}<br \/>\n\t\telse{<br \/>\n\t\techo &#8220;&#60;rssurl&#62;{$blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;]<br \/>[&#8216;rssurl&#8217;]}&#60;\/rssurl&#62;&#8221;;<br \/>\n\t\t}<br \/>\n\t\tif(empty($blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;]<br \/>[&#8216;atomurl&#8217;])){<br \/> <br \/>\n\t\techo &#8220;&#60;atomurl&#62;url not indexed&#60;\/atomurl&#62;&#8221;;}<br \/>\n\t\telse{<br \/>\t<br \/>\n\t\techo &#8220;&#60;atomurl&#62;{$blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;]<br \/>[&#8216;atomurl&#8217;]}&#60;\/atomurl&#62;&#8221;;<br \/>\n\t\t}<br \/>\t<br \/>\n\t\tif(empty($blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;][&#8216;lastupdate&#8217;])){<br \/> <br \/>\n\t\techo &#8220;&#60;lastupdate&#62;url not indexed&#60;\/lastupdate&#62;&#8221;;}<br \/>\n\t\telse {<br \/>\n\t\techo &#8220;&#60;lastupdate&#62;{$blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;]<br \/>[&#8216;lastupdate&#8217;]}&#60;\/lastupdate&#62;&#8221;;<br \/>\n\t\t}<br \/>\n\t\tif(empty($blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;][&#8216;foafurl&#8217;])){<br \/>\n\t\techo &#8220;&#60;foafurl&#62;url not indexed&#60;\/foafurl&#62;&#8221;;}<br \/>\n\t\telse{<br \/>\t<br \/>\n\t\techo &#8220;&#60;foafurl&#62;{$blog_url[&#8216;result&#8217;][&#8216;weblog&#8217;]<br \/>[&#8216;foafurl&#8217;]}&#60;\/foafurl&#62;&#8221;;<br \/>\n\t\t}<br \/>\n\t\techo &#8220;&#60;\/root&#62;\\n&#8221;;<br \/>\n?&#62;<\/div>\n<p>After the server-side, the client.<br \/>\nIn the simple HTML form I will insert the URL of my request: the event handler (In this example I choose an &#8220;onclick&#8221; in a button, but It could be an &#8220;onblur&#8221; in the text input, an &#8220;onmouseover&#8221; in a div etc&#8230;) call a the  javascript function <strong> getInfo()<\/strong> that will ask the infos to PHP.<br \/>\n&#8220;Loading&#8221; and &#8220;results&#8221; are two div where to insert a wait message and the results.<\/p>\n<div class=\"thecode\">\n&#60;form  method=&#8221;get&#8221;&#62;<br \/>\n  Blog Url:<br \/>\n  &#60;input type=&#8221;text&#8221; size=&#8221;25&#8243; id=&#8221;blog_url&#8221; value=&#8221;http:\/\/&#8221;\/&#62;<br \/>\n  &#60;input type=&#8221;button&#8221; value=&#8221;Get Info&#8221; onclick=&#8221;getInfo();&#8221; onkeypress=&#8221;getInfo();&#8221;\/&#62;<br \/>\n&#60;\/form&#62;<br \/>\n&#60;div id=&#8221;loading&#8221;&#62;&#60;\/div&#62;<br \/>\n&#60;div id=&#8221;results&#8221;&#62;&#60;\/div&#62;\n<\/div>\n<p>In the javascript, before call getInfo(), I must to create the XMLHttpRequest object, and then to handle the data from XML created by PHP with the function <strong>handleHttpResponse()<\/strong>, that creates an unordered list with infos inside.   <\/p>\n<div class=\"thecode\">\nvar http = getHTTPObject();<br \/>\nfunction getHTTPObject() {<br \/>\n  var xmlhttp;<br \/>\n  <span style=\"color: #999\">\/*@cc_on<br \/>\n  @if (@_jscript_version >= 5)<br \/>\n    try {<br \/>\n      xmlhttp = new ActiveXObject(&#8220;Msxml2.XMLHTTP&#8221;);<br \/>\n    } catch (e) {<br \/>\n      try {<br \/>\n        xmlhttp = new ActiveXObject(&#8220;Microsoft.XMLHTTP&#8221;);<br \/>\n      } catch (E) {<br \/>\n        xmlhttp = false;<br \/>\n      }<br \/>\n    }<br \/>\n  @else<br \/>\n  xmlhttp = false;<br \/>\n  @end @*\/<\/span><br \/>\n  if (!xmlhttp &#038;&#038; typeof XMLHttpRequest != &#8216;undefined&#8217;) {<br \/>\n    try {<br \/>\n      xmlhttp = new XMLHttpRequest();<br \/>\n\t  xmlhttp.overrideMimeType(&#8220;text\/xml&#8221;);<br \/> <br \/>\n    } catch (e) {<br \/>\n      xmlhttp = false;<br \/>\n    }<br \/>\n  }<br \/>\n  return xmlhttp;<br \/>\n} <\/p>\n<p>var isWorking = false;<br \/>\nvar url = &#8220;bloginfo.php?blog_url=&#8221;;<\/p>\n<p>function getInfo() {<br \/>\n document.getElementById(&#8216;results&#8217;).innerHTML =&#8217; &#8216;;<br \/>\n document.getElementById(&#8220;loading&#8221;).innerHTML = &#8216;Loading&#8230;&#8217;;<br \/>\n  if (!isWorking &#038;&#038; http) {<br \/>\n    var urlValue = document.getElementById(&#8220;urlV&#8221;).value;<br \/>\n    http.open(&#8220;GET&#8221;, url + escape(urlValue), true);<br \/>\n    http.onreadystatechange = handleHttpResponse;<br \/>\n    isWorking = true;<br \/>\n    http.send(null);<br \/>\n  }<br \/>\n}<\/p>\n<p>function handleHttpResponse() {<br \/>\n  if (http.readyState == 4) {<br \/>\n    if (http.responseText.indexOf(&#8216;invalid&#8217;) == -1) {<br \/>\n      var xmlDocument = http.responseXML; <br \/>\n      var name = xmlDocument.getElements<br \/>ByTagName(&#8216;name&#8217;).item(0).firstChild.data;<br \/>\n      var url = xmlDocument.getElements<br \/>ByTagName(&#8216;url&#8217;).item(0).firstChild.data;<br \/>\n      var inboundlinks =xmlDocument.getElements<br \/>ByTagName(&#8216;inboundlinks&#8217;).item(0).firstChild.data;<br \/>\n\t  var inboundblogs = xmlDocument.getElements<br \/>ByTagName(&#8216;inboundblogs&#8217;).item(0).firstChild.data;<br \/>\n      var rank = xmlDocument.getElements<br \/>ByTagName(&#8216;rank&#8217;).item(0).firstChild.data;<br \/>\n      var rssurl = xmlDocument.getElements<br \/>ByTagName(&#8216;rssurl&#8217;).item(0).firstChild.data;<br \/>\n      var atomurl = xmlDocument.getElements<br \/>ByTagName(&#8216;atomurl&#8217;).item(0).firstChild.data;<br \/>\n      var lastupdate = xmlDocument.getElements<br \/>ByTagName(&#8216;lastupdate&#8217;).item(0).firstChild.data;<br \/>\n      var foafurl = xmlDocument.getElements<br \/>ByTagName(&#8216;foafurl&#8217;).item(0).firstChild.data;<br \/>\n      var u= document.createElement(&#8216;ul&#8217;);<br \/>\n      document.getElementById(&#8216;results&#8217;).appendChild(u);<br \/>\n  \t  u.innerHTML =<br \/>\n\t  &#8216;&#60;li&#62;&#60;strong&#62;Blog name:&#60;\/strong&#62; &#8216;+name+&#8217;&#60;\/li&#62;&#8217;+<br \/>\n\t  &#8216;&#60;li&#62;&#60;strong&#62;URL:&#60;\/strong&#62; &#8216;+url+&#8217;&#60;\/li&#62;&#8217;+<br \/>\n\t  &#8216;&#60;li&#62;&#60;strong&#62;Inbound links:&#60;\/strong&#62; &#8216;+inboundlinks+&#8217;&#60;\/li&#62;&#8217;+<br \/>\n\t  &#8216;&#60;li&#62;&#60;strong&#62;Inbound blogs:&#60;\/strong&#62; &#8216;+inboundblogs+&#8217;&#60;\/li&#62;&#8217;+<br \/>\n\t  &#8216;&#60;li&#62;&#60;strong&#62;Technorati Rank:&#60;\/strong&#62; &#8216;+rank+&#8217;&#60;\/li&#62;&#8217;+<br \/>\n\t  &#8216;&#60;li&#62;&#60;strong&#62;URL RSS:&#60;\/strong&#62; &#8216;+rssurl+&#8217;&#60;\/li&#62;&#8217;+<br \/>\n\t  &#8216;&#60;li&#62;&#60;strong&#62;URL Atom:&#60;\/strong&#62; &#8216;+atomurl+&#8217;&#60;\/li&#62;&#8217;+<br \/>\n\t  &#8216;&#60;li&#62;&#60;strong&#62;Last update:&#60;\/strong&#62; &#8216;+lastupdate+&#8217;&#60;\/li&#62;&#8217;+<br \/>\n\t  &#8216;&#60;li&#62;&#60;strong&#62;URL FOAF:&#60;\/strong&#62; &#8216;+foafurl+&#8217;&#60;\/li&#62;&#8217;;<br \/>\n      document.getElementById(&#8220;loading&#8221;).innerHTML = &#8216;The results:&#8217;;<br \/>\n \t  isWorking = false;<br \/>\n    }<br \/>\n  }<br \/>\n}\n<\/div>\n<p>You can download the three scripts <a href=\"http:\/\/www.centralscrutinizer.it\/en\/test\/tech_info.zip\">here<\/a>, next time (I think tomorrow) another experiment about the same topic.<br \/>\n(ah, some links:<br \/>\n-&#62;<a href=\"http:\/\/developers.technorati.com\/wiki\/TechnoratiApi\">Technorati API<\/a><br \/>\n-&#62;<a href=\"http:\/\/www.kailashnadh.name\/ducksoup\/\">Duck Soup<\/a><br \/>\n-&#62;<a href=\"http:\/\/www.webpasties.com\/xmlHttpRequest\/index.html\">A guide to XMLHttpRequest<\/a><br \/>)<br \/>\n See you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Inspired by the swiss example, one week ago Luca Conti launched the proposal to create an italian blogs ranking based on Technorati. To the point, searching for a simple way to made it, I found and suggested Duck Soup, a PHP library that allow simple utilization of all the infos served by Technorati&#8217;s APIs. Using [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-245","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/centralscrutinizer.it\/italiano\/wp-json\/wp\/v2\/pages\/245"}],"collection":[{"href":"https:\/\/centralscrutinizer.it\/italiano\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/centralscrutinizer.it\/italiano\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/centralscrutinizer.it\/italiano\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/centralscrutinizer.it\/italiano\/wp-json\/wp\/v2\/comments?post=245"}],"version-history":[{"count":0,"href":"https:\/\/centralscrutinizer.it\/italiano\/wp-json\/wp\/v2\/pages\/245\/revisions"}],"wp:attachment":[{"href":"https:\/\/centralscrutinizer.it\/italiano\/wp-json\/wp\/v2\/media?parent=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}