Making an HTTP request.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Making an HTTP request.

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Making an HTTP request.

Post by Christopher »

cURL or if you don't have that installed then the Snoopy class is really good.
(#10850)
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Re: Making an HTTP request.

Post 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');
 
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Re: Making an HTTP request.

Post 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. :(
Post Reply