Okay, I'm trying to use Yahoo pipes (output=PHP). I've used the code below to get what you can see here. I NEED to know how to turn that array information into this kind of format: Title Street City, State Phone <?php error_reporting(E_ALL); // output=php means that the request will return serialized PHP $request = 'http://pipes.yahoo.com/pipes/pipe.run?Location=98229&_id=ffa43b51699a926981d210f575d8ed6b&_render=php&subject=apartment'; $response = file_get_contents($request); if ($response === false) { die('Request failed'); } $phpobj = unserialize($response); echo '<pre>'; print_r($phpobj); echo '</pre>'; ?> PHP: THANK YOU FOR YOUR HELP!
foreach ($phpobj['value']['items'] as $business) $content .= "{$business['title']}<br />{$business['y:location']['street']}<br />{$business['y:location']['city']}, {$business['y:location']['state']}<br />{$business['phone']}<br /><br />"; echo $content; Code (markup): I haven't tried it but that should work.
rcadble... thanks, that pretty much works great! Only problem is I get this error message: Notice: Undefined variable: content in /home/chinedu8/public_html/pipes_local_api.php on line 18 Here is the code again: <?php error_reporting(E_ALL); // output=php means that the request will return serialized PHP $request = 'http://pipes.yahoo.com/pipes/pipe.run?Location=98229&_id=ffa43b51699a926981d210f575d8ed6b&_render=php&subject=apartment'; $response = file_get_contents($request); if ($response === false) { die('Request failed'); } $phpobj = unserialize($response); foreach ($phpobj['value']['items'] as $business) $content .= "{$business['title']}<br />{$business['y:location']['street']}<br />{$business['y:location']['city']}, {$business['y:location']['state']}<br />{$business['Phone']}<br /><br />"; echo $content; ?> PHP:
It's because of the strict errorreporting I think. Try this: <?php error_reporting(E_ALL); // output=php means that the request will return serialized PHP $request = 'http://pipes.yahoo.com/pipes/pipe.run?Location=98229&_id=ffa43b51699a926981d210f575d8ed6b&_render=php&subject=apartment'; $response = file_get_contents($request); if ($response === false) { die('Request failed'); } $phpobj = unserialize($response); $content = ''; foreach ($phpobj['value']['items'] as $business) $content .= "{$business['title']}<br />{$business['y:location']['street']}<br />{$business['y:location']['city']}, {$business['y:location']['state']}<br />{$business['Phone']}<br /><br />"; echo $content; ?> Code (markup):
rcadble, that works great... two questions though. Is there a way to limit the results AND could I use this same code to display listings from this page (http://developer.trulia.com/docs/LocationInfo/getNeighborhoodsInCity) by only tweaking the $business['title'] stuff?: It doesn't seem to work for that
I'm not sure about your second question, but you can limit the results. <?php error_reporting(E_ALL); // output=php means that the request will return serialized PHP $request = 'http://pipes.yahoo.com/pipes/pipe.run?Location=98229&_id=ffa43b51699a926981d210f575d8ed6b&_render=php&subject=apartment'; $response = file_get_contents($request); if ($response === false) { die('Request failed'); } $phpobj = unserialize($response); $limit = 20; //edit this to the limit $count = 0; foreach ($phpobj['value']['items'] as $business) { $content .= "{$business['title']}<br />{$business['y:location']['street']}<br />{$business['y:location']['city']}, {$business['y:location']['state']}<br />{$business['Phone']}<br /><br />"; $count ++; if ($count >= $limit) break; } echo $content; ?> Code (markup):