close

  
<p> //provide a jsonp interface to cool new google api

//this is my key, please use yours instead
var key='AIzaSyAZTu7DGvKIoM7xEFcIXJ0EGJ-48Mt2Tw4'

  var callback = acre.request.params["callback"];
  var urls = acre.request.params["urls"] || [];
  if (callback != null &amp;&amp; callback.length == 0) {
    callback = null;
  } 

  var result= urls.map(function(url){
          if(url){
          var url='https://www.googleapis.com/freebase/v1/search?key='+key+'&amp;limit=4&amp;query='+encodeURIComponent(url)
          var result=JSON.parse(acre.urlfetch(url).body).result || [];
          result=result[0];
          try{
            result.description=acre.freebase.get_blob(v.mid,'blurb').body||'';
            result.description=result.description.replace(/ \(.*?\)/,''); 
          }catch(e){}  
          return result[0]
        } 
      }) 



console.log(result)     

  if (callback != null) {
    acre.write(callback + "(");
  }
    acre.write(JSON.stringify(result));
  if (callback != null) {
    acre.write(")");
  }
  
 </p>

Comments

Hide