/    Sign up×
Community /Pin to ProfileBookmark

Making a call to API with PHP

I am trying to use
[B]Zillow API [/B]
But I dont know how to make the call.
They say tomake the call with [B]http://www.zillow.com/webservice/GetZestimate.htm?zws-id=<ZWSID>&zpid=48749425[/B]

but i dont know if i have to use a $variable = http://www.zillow.com/webservice/GetZestimate.htm?zws-id=<ZWSID>&zpid=48749425

or how ?

Thanks for the help

[url]http://www.zillow.com/howto/api/GetZestimate.htm[/url]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 22.2009 — If your PHP config has allow_url_fopen enabled, you could just do a file_get_contents() on the url:
[code=php]
$result = file_get_contents('http://blah/blah/blah/blah...');
[/code]

If, however, that is not feasible, you might have to use the [url=http://php.net/curl]cURL extension[/url].
Copy linkTweet thisAlerts:
@moiseszaragozaauthorAug 01.2009 — Thanks for the help.

I am calling

[code=php]

<?php
$citystatezip = "33308";
$result = file_get_contents('http://www.zillow.com/webservice/GetZestimate.htm?zws-id=xxxxxx&zpid='.$citystatezip.'');
echo($result);

//OUT UPT
/*

33308 Request successfully processed 0 33308 http://www.zillow.com/homedetails/7660-Big-Spruce-Cir-Anchorage-AK-99502/33308_zpid/ http://www.zillow.com/homedetails/charts/33308_zpid,1year_chartDuration/?cbt=6757670776277091874&#37;7E6%7EtvFRjxH1Sths0B3BStcmJPiDdw3flU0c49Z8-sri4ToddyHk46yhBA** http://www.zillow.com/homes/map/33308_zpid/ http://www.zillow.com/myestimator/Edit.htm?zprop=33308 http://www.zillow.com/myestimator/Edit.htm?zprop=33308 http://www.zillow.com/homes/comps/33308_zpid/
7660 Big Spruce Cir 99502 Anchorage AK 61.151268 -149.945683
320000 07/31/2009 -5000 288000 361600 62 298,479 0.031 http://www.zillow.com/local-info/AK-Anchorage/Sand-Lake/r_267851/ http://www.zillow.com/homes/fsbo/Sand-Lake-Anchorage-AK/ http://www.zillow.com/homes/for_sale/Sand-Lake-Anchorage-AK/ 303,626 0.029 http://www.zillow.com/local-info/AK-Anchorage/r_23482/ http://www.zillow.com/homes/fsbo/Anchorage-AK/ http://www.zillow.com/homes/for_sale/Anchorage-AK/ 213,028 0.016 http://www.zillow.com/local-info/AK-home-value/r_3/ http://www.zillow.com/homes/fsbo/AK/ http://www.zillow.com/homes/for_sale/AK/ 100221 23482 2616 3
*/

?>
[/code]



But how do i display the data?
Copy linkTweet thisAlerts:
@chrisranjanaAug 04.2009 — That can be done in a number of ways.

You need to use either php split or php preg_match to extract your required data from the API call's output.
Copy linkTweet thisAlerts:
@SodbusterAug 05.2009 — The API call's output is XML, so using string or regex functions to extract the data would be doing it the hard way.

The output you're echoing is not the complete server output; change [I]echo $result[/I] to [I]echo nl2br(htmlspecialchars($result))[/I] to see the XML document.
Copy linkTweet thisAlerts:
@NogDogAug 05.2009 — It the returned value is XML, you could use the [url=http://php.net/simplexml]SimpleXML[/url] or the [url=http://php.net/dom]DOM[/url] extensions to parse it.
×

Success!

Help @moiseszaragoza spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...