0

YUI and YQL

Hi there, I am new and learning YUI and YQL on my own.

I am reading the YUI3 cookbook about fetching data from YQL.

The example that I looked at was Fetching and displaying data with YQL

Now I am trying to try out using YQL to read extract data from an api in json format.

My first difficulty is that, if I were to use select * from html where url="api url &format=json&apiKey=t4aybcb6rd8xb8sgkk9rb9gh", the output comes in a

<

pre> tag and the output looks like {"productDetails":{"products":[{"material":"100303","description":"12ZCAN 4X6P Jellybean"},

Can someone suggest any examples which I can look at to help me understand how to generate this into an ordered list ?

by
  • D
  • Aug 14, 2013
2 Replies
  • You build a HTML list on the similar lines like this code

    view source and you will see code like this

    <html>
    <head>
        <title>
            Flickr Example
        </title>
        <style type="text/css">
        img{
            <margin:10px;>
            padding: 10px;
        }
        </style>
       <script type="text/javascript">
         function foo(data){
           var photos=data.query.results.photo;
           var html="",img="";
           for(var i=0;i<photos.length;i++){
              console.log(photos[i]);
              img="<http://farm>{farm-id}.staticflickr.com/{server-id}/{id}_{secret}_n.jpg";
              img=img.replace('{farm-id}',photos[i].farm);
              img=img.replace('{server-id}',photos[i].server);
              img=img.replace('{secret}',photos[i].secret);
              img=img.replace('{id}',photos[i].id);
              html=html+"<img src='"+img+"'/>";
           }
           document.getElementById("img").innerHTML=html;
         }
       </script>
    </head>
    <body>
        <div id="main">
        <div id="img">
    
        </div>  
      <a href="<http://www.twitter.com/markandey>">Mashup by: Markandey</a>
        </div>
    </body>
    <script src="<http://query.yahooapis.com/v1/public/yql?q=select%20>*%20from%20flickr.photos.interestingness(20)%20where%20api_key%3D%20'0fbb2b721757f77a6a9d038f4649a2bf'&format=json&diagnostics=true&callback=foo"></script>
    </html>
    
    0
    • D
    • Aug 22, 2013

    Thanks. will look into the example provided.

    0

Recent Posts

in YQL