tags:

views:

14

answers:

0

Ok, i have a JSON parser in my iphone app and i'm trying to return rss feeds from google or yahoo to the app via this php script. can anyone see where i'm going wrong with this php, thanks. it comes back to the app as gobbledegook, not parsed at all

<?php
        header("Content-Type: application/json");
        $yqlUrl = "http://query.yahooapis.com/v1/public/yql";
        $query = "select * from weather.forecast where location=90210"; 
        $queryUrl =  
            $yqlUrl . 
            "?q=" . urlencode($query) . 
            "&format=json" .
            "&env=" . urlencode("store://datatables.org/alltableswithkeys");

        $session = curl_init($queryUrl);
        curl_setopt($session, CURLOPT_HEADER, false); 
        curl_setopt($session, CURLOPT_RETURNTRANSFER, true);  
        $json = curl_exec($session); 
        curl_close($session);
        $yqlObject = json_decode($json);
        $array = Array();
        $array[] = $yqlObject;
        echo json_encode($array);  
    ?>