Trulia API...

Discussion in 'PHP' started by cgo85, Aug 25, 2008.

  1. #1
    Can someone please point me in the right direction of how to pull basic neighborhood listings from this: http://developer.trulia.com/docs/LocationInfo/getNeighborhoodsInCity

    Is there a way to manipulate this script correctly:

    <?php
    
    error_reporting(E_ALL);
    
    // output=php means that the request will return serialized PHP
    $request =  'http://api.trulia.com/webservices.php?library=LocationInfo&function=
    getNeighborhoodsInCity&city=Los Angeles&state=CA&apikey=my_key&output=php';
    
    $response = file_get_contents($request);
    
    if ($response === false) {
    die('Request failed');
    }
    
    $phpobj = unserialize($response);
    
    $content = '';
    foreach ($phpobj['value']['items'] as $business)
    $content .= "<u>{$business['title']}</u>:{$business['y:location']['street']} {$business['y:location']['city']}, {$business['y:location']['state']} -- {$business['Phone']}<br />";
    echo $content;
    
    ?>
    PHP:
     
    cgo85, Aug 25, 2008 IP