0
<?php 
include_once("zillow_api.php");
$zws_id = "*****************";
$zillow_api = new Zillow_Api($zws_id); // $zws_id is your Zillow API Key
$search_result = $zillow_api->GetSearchResults(array('address' => '7356 CARTER AVE',     'citystatezip' => 'NEWARK'));

$data = json_decode( json_encode($search_result) , 1);
var_dump($data);

print_r($data->request);


?>

上面的 PHP 代码

结果如下:

array(3) { ["request"]=> array(2) { ["address"]=> string(15) "7356 CARTER AVE" ["citystatezip"]=> string(6) "NEWARK" } ["message"]=> array(2) { ["text"]=> string(30) "Request successfully processed" ["code"]=> string(1) "0" } ["response"]=> array(1) { ["results"]=> array(1) { ["result"]=> array(5) { ["zpid"]=> string(8) "52932643" ["links"]=> array(4) { ["homedetails"]=> string(80) "zillow.com/homedetails/7356-Carter-Ave-Newark-CA-94560/52932643_zpid/" ["graphsanddata"]=> string(96) "zillow.com/homedetails/7356-Carter-Ave-Newark-CA-94560/52932643_zpid/#charts-and-data" ["mapthishome"]=> string(42) "http://www.zillow.com/homes/52932643_zpid/" ["comparables"]=> string(48) "http://www.zillow.com/homes/comps/52932643_zpid/" } ["address"]=> array(6) { ["street"]=> string(15) "7356 Carter Ave" ["zipcode"]=> string(5) "94560" ["city"]=> string(6) "Newark" ["state"]=> string(2) "CA" ["latitude"]=> string(9) "37.529165" ["longitude"]=> string(11) "-122.039157" } ["zestimate"]=> array(6) { ["amount"]=> string(6) "703264" ["last-updated"]=> string(10) "06/12/2014" ["oneWeekChange"]=> array(1) { ["@attributes"]=> array(1) { ["deprecated"]=> string(4) "true" } } ["valueChange"]=> string(5) "23695" ["valuationRange"]=> array(2) { ["low"]=> string(6) "668101" ["high"]=> string(6) "738427" } ["percentile"]=> string(1) "0" } ["localRealEstate"]=> array(1) { ["region"]=> array(2) { ["@attributes"]=> array(3) { ["id"]=> string(5) "49611" ["type"]=> string(4) "city" ["name"]=> string(6) "Newark" } ["links"]=> array(3) { ["overview"]=> string(51) "zillow.com/local-info/CA-Newark/r_49611/" ["forSaleByOwner"]=> string(37) "zillow.com/newark-ca/fsbo/" ["forSale"]=> string(32) "zillow.com/newark-ca/" } } } } } } } 

我想在 php 中显示结果

print_r($data->response->result->zpid); // i use this what getting error 

注意:尝试在第 14 行的 E:\xampp\htdocs\work\zillow\zillow.php 中获取非对象的属性

4

1 回答 1

2

这是你的代码:

$data = json_decode( json_encode($search_result) , 1);

像这样更改您的代码(将true替换为1)

$data = json_decode( json_encode($search_result) , true);
于 2014-06-15T18:59:27.930 回答