title: Retrieve YQL with PHP and json
body: <p>I want to get the code element of the weather forecast of this YQL query , the problem is that this returns me null.</p>
  
  <pre><code>                        php
            var_dump(getResultFromYQL());
  
          function getResultFromYQL(  ) {
  
             $yql_query_url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%3D946738&amp;format=json&amp;diagnostics=true&amp;callback=?";
  
              $session = curl_init($yql_query_url);
              curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
  
              $json = curl_exec($session);
              curl_close($session);
  
              return json_decode($json);
          }
          ?&gt;
  </code></pre>
  
  <p>OK I found the Solution
                   php</p>
  
  <pre><code>            $Jakarta = 946738;  /* Jakarta */
  
  
              /* Use cURL to query the API for some XML */
              $ch = curl_init();
              curl_setopt($ch, CURLOPT_URL, 'http://weather.yahooapis.com/forecastrss?w='.$Jakarta.'&amp;u=f');
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
              $weather_rss = curl_exec($ch);
              curl_close($ch);
  
              /* Create an object of the XML returned */
              $weather = new SimpleXMLElement($weather_rss);
  
              /*
              * Since I don't want to figure out an image system, I'll use Weather.com's (what Yahoo does)
              * by pulling the image directly out of the returned API request. This could be done better.
              */
              $weather_contents = $weather-&gt;channel-&gt;item-&gt;description;
              //  preg_match_all('/&lt;img[^&gt;]+&gt;/i',$weather_contents, $img);
              //  $weather_img = $img[0][0];
  
              /* Get clean parts */
  
              $weather_cond = $weather-&gt;channel-&gt;item-&gt;xpath('yweather:condition');
  
  
              /* Function to convert Wind Direction from given degree units into Cardinal units */
  
              ?&gt;
  
  
                               hp
  
                                           print $weather_cond[0]-&gt;attributes()-&gt;code;
  
                                ?&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;/div&gt;
  </code></pre>