Skip to content

Instantly share code, notes, and snippets.

@jzmwebdevelopment
Created November 29, 2012 00:42
Show Gist options
  • Save jzmwebdevelopment/4165893 to your computer and use it in GitHub Desktop.
Save jzmwebdevelopment/4165893 to your computer and use it in GitHub Desktop.
Full Function
public function propertyDetailsSections()
{
$categoryDetails = $this->createCategoryDetails();
$open2ViewInformation = $this->getOpen2ViewInfotmation();
$category = array();
foreach ($categoryDetails as $id) {
$Json = file_get_contents('http://api.trademe.co.nz/v1/Listings/'.$id['listingId'].'.json');
$dataDecode = json_decode($Json, true);
$data = array($dataDecode);
$details = array();
$photos = array();
foreach ($data as $key => $detail)
{
$catNameO = $detail['CategoryName'];
$catName = str_replace(" ", "-", $catNameO);
$defaultDescription = $detail['Body'];
$description = preg_replace('/\s\s+/','<br/><br/>', $defaultDescription);
if($catName == 'Sections-for-sale')
{
$streetAddressO = $detail['Attributes']['3']['Value'];
$street = explode(" ", $streetAddressO);
$suburb = $detail['Attributes']['5']['Value'];
$region = $detail['Attributes']['6']['Value'];
$address = $street[0]." ".$street[1]." ".$street[2]." ".$suburb.", ".$region;
foreach($open2ViewInformation as $open)
{
if($open['address'] == $address)
{
$photos[] = array($open2ViewInformation['photo']);
}else{
foreach($detail['Photos'] as $key => $image)
{
$photos[] = array($image['Value']['FullSize']);
}
}
}
echo '<pre>';
var_dump($detail);
echo '</pre>';
$details[] = array( 'priceName' => $detail['Attributes'][2]['DisplayName'],
'priceValue' => $detail['Attributes'][2]['Value'],
'locationName' => $detail['Attributes'][3]['DisplayName'],
'locationValue' => $detail['Attributes'][3]['Value'],
'landAreaName' => $detail['Attributes'][7]['DisplayName'],
'landAreaValue' => $detail['Attributes'][7]['Value'],
'description' => $description,
'photos' => $photos
);
}
}
//return $details;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment