Page 1 of 1

Making an HTTP request.

Posted: Wed May 21, 2008 12:49 am
by JellyFish
How can I make an HTTP request in php? I tried http_get and http_request functions and it I get an error, call to undefined function.

Is there any simple way to return the RSS XML from yahoo weather? I'm trying to return the XML of yahoo weather and then use XML functions on the feed and then return a sorta textual/JSON format of the data of my choosing.

I just need a simple way to get the response of "http://weather.yahooapis.com/forecastrss?p=94089&u=c".

Thanks for reading, all help is appreciated on this.

Re: Making an HTTP request.

Posted: Wed May 21, 2008 1:08 am
by Christopher
cURL or if you don't have that installed then the Snoopy class is really good.

Re: Making an HTTP request.

Posted: Wed May 21, 2008 1:51 am
by andre_c
If you're using PHP5 and all you need is a GET request, you can simply do:

Code: Select all

 
$response = file_get_contents('http://someserver.com/some/path?some=params');
 

Re: Making an HTTP request.

Posted: Wed May 21, 2008 4:17 am
by JellyFish
Wowy the cURL lib works great.

The only other problem I'm having is the XML parsing side. Or would this require another topic.

Btw I'm using php 4 so no new stuff for me. :(